﻿namespace = fund_inspiration


#########################
# MAINTENANCE EVENTS
# by Linnéa Thimrén, Sean Hughes & Bianca Savazzi
#########################
# You funded an inspiration (0001-1000)
#	fund_inspiration.0001 - Fallback version
#	fund_inspiration.0011 - Weapon (Chose what they make)
# 	fund_inspiration.0012 - Weapon (They know what they want to make)
# 	fund_inspiration.0021 - Armor (Decide type of armor)
# 	fund_inspiration.0022 - Armor (They choose armor type)
#	fund_inspiration.0031 - Book (Choose subject)
#	fund_inspiration.0032 - Book (They have a subject)
#	fund_inspiration.0041 - Tapestry (Choose a subject)
#	fund_inspiration.0042 - Tapestry (Subject already chosen)
#	fund_inspiration.0051 - Adventurer (Choose destination)
#	fund_inspiration.0052 - Adventurer (Destination already chosen)
#	fund_inspiration.0061 - Artisan (Choose what they make)
#	fund_inspiration.0062 - Artisan (They know what they want to make)
#	fund_inspiration.0071 - Smith (Choose what they make)
#	fund_inspiration.0072 - Smith (They know what they want to make)
#	fund_inspiration.0081 - Alchemist (Choose what they make)
#	fund_inspiration.0082 - Alchemist (They know what they want to make)

# Inspiration: complete! (1001-2000)
#	fund_inspiration.1001 - Fallback version
#	fund_inspiration.1011 - Weapon artifact
#	fund_inspiration.1021 - Armor artifact
#	fund_inspiration.1031 - Book artifact
# 	fund_inspiration.1041 - Weaver artifact
#	fund_inspiration.1051 - Adventurer returns with artifact
#	fund_inspiration.1061 - Artisan artifact
#	fund_inspiration.1071 - Smith artifact
#	fund_inspiration.1081 - Alchemy artifact

# Inspiration invalidated (9001-9999)
#	fund_inspiration.9001 - The inspired character died
#	fund_inspiration.9002 - The inspired character is imprisoned
#	fund_inspiration.9003 - The inspired character is no longer courtier of sponsor
#	fund_inspiration.9004 - Adventurer returns prematurely
#   fund_inspiration.9005 - Sponsorship inheritance confirmation


#########################
# ONGOING EVENTS (2001-9000)
# by Linnéa Thimrén, Bianca Savazzi, Isabella Welch, and Claudia Baldassi
#########################
# fund_inspiration.2001 - Inspiration owner asks for more money
# fund_inspiration.2002 - Inspiration owner asks for more human material
# fund_inspiration.2003 - Previously inspiration owner helps current one in their creation
# fund_inspiration.2004 - A merchant selling high-quality materials is in town
# fund_inspiration.2005 - Smith (weapon/armor/smith) asks you to invest in a better forge
# fund_inspiration.2006 - A wise person visits
# fund_inspiration.2021 - Inspiration owner asks for more money (armor specific)
# fund_inspiration.3001 - Court Chaplain complains about book subject
# fund_inspiration.3011 - Book (Martial) - wanna nudge the content?
# fund_inspiration.3012 - Book (Diplomacy) - wanna nudge the content?
# fund_inspiration.3013 - Book (Learning) - wanna nudge the content?
# fund_inspiration.3014 - Book (Stewardship) - wanna nudge the content?
# fund_inspiration.3015 - Book (Intrigue) - wanna nudge the content?
# fund_inspiration.3030 - Book - Nemesis is no longer nemesis and you're writing about your hatred
# fund_inspiration.3031 - Book - Soulmate is no longer soulmate and you're writing about your love
# fund_inspiration.4001 - Weaver - Weaver is stealing clothes
# fund_inspiration.5011 - Adventurer - Choose your item-type
# fund_inspiration.5021 - Adventurer gets lost... this can be a good thing though
# fund_inspiration.6001 - Adventurer postcard from the Steppe
# fund_inspiration.6002 - Adventurer postcard from India
# fund_inspiration.6003 - Adventurer postcard from Africa
# fund_inspiration.6004 - Adventurer postcard from the Middle East
# fund_inspiration.6005 - Adventurer postcard from Europe
# fund_inspiration.6006 - Adventurer postcard from Asia Minor
# fund_inspiration.6100 - Artisan chest prototype
# fund_inspiration.6101 - Artisan box prototype
# fund_inspiration.6102 - Artisan sculpture prototype
# fund_inspiration.6103 - Artisan chest prototype
# fund_inspiration.6104 - Artisan cabinet prototype
# fund_inspiration.6105 - Ruler collected all of the prototype artisan furniture
# fund_inspiration.6200 - Weaver - Weaver is too much of a modernist
# fund_inspiration.6400 - Adventurer has been skulking in the tavern
# fund_inspiration.8001 - Alchemy (Metal) - what subtype?
# fund_inspiration.8011 - Alchemy - Get poisoned by a bad alchemist
# fund_inspiration.8012 - Alchemy - Church disproves of you employing an alchemist
# fund_inspiration.8013 - Alchemy - Find a book from alchemist Jabir ibn Hayyan
# fund_inspiration.8014 - Alchemy - Alchemist isn't producing anything
# fund_inspiration.8015 - Alchemy - Plead with alchemist to resurrect family member/friend
# fund_inspiration.8017 - Alchemy - Helping the court tutor

##########################################################################################


#only here for testing
#Give progress to random sponsored inspiration
fund_inspiration.9999 = {
	type = character_event
	title = fund_inspiration.9999.t
	desc = fund_inspiration.9999.desc
	theme = realm
	orphan = yes
	left_portrait = {
		character = scope:recipient
		animation = personality_honorable
	}

	immediate = {

	}

	#
	option = {
		name = fund_inspiration.9999.a
		random_sponsored_inspiration = {
			change_inspiration_progress = 20
		}
	}
}

#An effect used to clean up all variables etc. Should always be used in the "after" of a completion event!
scripted_effect inspiration_completion_removal_basic_effect = {
	if = {
		limit = { has_variable = book_artifact_subject }
		remove_variable = book_artifact_subject
	}
	if = {
		limit = { has_variable = book_artifact_topic }
		remove_variable = book_artifact_topic
	}
	if = {
		limit = { has_variable = book_topic_category }
		remove_variable = book_topic_category
	}
	if = {
		limit = { has_variable = book_subject_witch_scope }
		remove_variable = book_subject_witch_scope
	}
	if = {
		limit = { has_variable = quality }
		remove_variable = quality
	}
	if = {
		limit = { has_variable = wealth }
		remove_variable = wealth
	}
	if = {
		limit = { has_variable = book_content_quality }
		remove_variable = book_content_quality
	}
	if = {
		limit = { has_variable = animal_type }
		remove_variable = animal_type
	}
	if = {
		limit = { has_variable = book_topic_cat_name }
		remove_variable = book_topic_cat_name
	}
	if = {
		limit = { has_variable = book_topic_dog_name }
		remove_variable = book_topic_dog_name
	}
	if = {
		limit = { has_variable = book_topic_united_title }
		remove_variable = book_topic_united_title
	}
	if = {
		limit = { has_variable = book_topic_created_title }
		remove_variable = book_topic_created_title
	}
	if = {
		limit = { has_variable = book_topic_restored_title }
		remove_variable = book_topic_restored_title
	}
	if = {
		limit = { has_variable = relevant_title }
		remove_variable = relevant_title
	}
	if = {
		limit = { has_variable = artifact_tapestry_scene }
		remove_variable = artifact_tapestry_scene
	}
	if = {
		limit = { has_variable = adventure_artifact_location }
		remove_variable = adventure_artifact_location
	}
	if = {
		limit = { has_variable = artifact_weapon_type }
		remove_variable = artifact_weapon_type
	}
	if = {
		limit = { has_variable = artifact_armor_type }
		remove_variable = artifact_armor_type
	}
	if = {
		limit = { has_variable = artifact_artisan_type }
		remove_variable = artifact_artisan_type
	}
	if = {
		limit = { has_variable = adventure_destination }
		remove_variable = adventure_destination
	}
	if = {
		limit = { has_variable = artifact_smith_type }
		remove_variable = artifact_smith_type
	}
	if = {
		limit = { has_variable = adventure_type }
		remove_variable = adventure_type
	}
	if = {
		limit = { has_variable = local_artisan }
		remove_variable = local_artisan
	}
	if = {
		limit = { has_variable = wealth }
		remove_variable = wealth
	}
	if = {
		limit = { has_variable = quality }
		remove_variable = quality
	}
	if = {
		limit = { has_variable = artifact_quality }
		remove_variable = artifact_quality
	}
	if = {
		limit = { has_variable = artifact_dedication_var }
		remove_variable = artifact_dedication_var
	}
	if = {
		limit = { has_variable = artifact_dedication_a_var }
		remove_variable = artifact_dedication_a_var
	}
	if = {
		limit = { has_variable = artifact_dedication_b_var }
		remove_variable = artifact_dedication_b_var
	}
	if = {
		limit = { has_variable = artifact_dedication_d_var }
		remove_variable = artifact_dedication_d_var
	}
	if = {
		limit = { has_variable = artifact_dedication_e_var }
		remove_variable = artifact_dedication_e_var
	}
	if = {
		limit = { has_variable = artifact_dedication_f_var }
		remove_variable = artifact_dedication_f_var
	}
	if = {
		limit = { has_variable = artifact_dedication_g1_var }
		remove_variable = artifact_dedication_g1_var
	}
	if = {
		limit = { has_variable = artifact_dedication_g2_var }
		remove_variable = artifact_dedication_g2_var
	}
	if = {
		limit = { has_variable = artifact_dedication_h_var }
		remove_variable = artifact_dedication_h_var
	}
	if = {
		limit = { has_variable = artifact_inscribe_motto_var }
		remove_variable = artifact_inscribe_motto_var
	}
	if = {
		limit = { has_variable = gone_adventuring }
		remove_variable = gone_adventuring
	}
}

scripted_effect inspiration_completion_effect = {
	if = {
		limit = { exists = scope:owner }
		scope:owner = {
			inspiration_completion_removal_basic_effect = yes
		}
	}
	if = {
		limit = { exists = scope:inspiration_sponsor }
		scope:inspiration_sponsor = {
			inspiration_completion_removal_basic_effect = yes
		}
	}
	if = {
		limit = { exists = scope:inspiration_owner }
		scope:inspiration_owner = {
			inspiration_completion_removal_basic_effect = yes
			# They might also have a bunch of blocker-flags saved from events
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_2001 }
				remove_character_flag = had_event_fund_inspiration_2001
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_2002 }
				remove_character_flag = had_event_fund_inspiration_2002
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_2003 }
				remove_character_flag = had_event_fund_inspiration_2003
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_2004 }
				remove_character_flag = had_event_fund_inspiration_2004
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_2005 }
				remove_character_flag = had_event_fund_inspiration_2005
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_2006 }
				remove_character_flag = had_event_fund_inspiration_2006
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_2021 }
				remove_character_flag = had_event_fund_inspiration_2021
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_3001 }
				remove_character_flag = had_event_fund_inspiration_3001
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_3011 }
				remove_character_flag = had_event_fund_inspiration_3011
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_3012 }
				remove_character_flag = had_event_fund_inspiration_3012
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_3013 }
				remove_character_flag = had_event_fund_inspiration_3013
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_3014 }
				remove_character_flag = had_event_fund_inspiration_3014
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_3015 }
				remove_character_flag = had_event_fund_inspiration_3015
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_3030 }
				remove_character_flag = had_event_fund_inspiration_3030
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_3031 }
				remove_character_flag = had_event_fund_inspiration_3031
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_4001 }
				remove_character_flag = had_event_fund_inspiration_4001
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_5011 }
				remove_character_flag = had_event_fund_inspiration_5011
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_5021 }
				remove_character_flag = had_event_fund_inspiration_5021
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_6001 }
				remove_character_flag = had_event_fund_inspiration_6001
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_6002 }
				remove_character_flag = had_event_fund_inspiration_6002
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_6003 }
				remove_character_flag = had_event_fund_inspiration_6003
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_6004 }
				remove_character_flag = had_event_fund_inspiration_6004
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_6005 }
				remove_character_flag = had_event_fund_inspiration_6005
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_6006 }
				remove_character_flag = had_event_fund_inspiration_6006
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_8001 }
				remove_character_flag = had_event_fund_inspiration_8001
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_8011 }
				remove_character_flag = had_event_fund_inspiration_8011
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_8012 }
				remove_character_flag = had_event_fund_inspiration_8012
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_8013 }
				remove_character_flag = had_event_fund_inspiration_8013
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_8014 }
				remove_character_flag = had_event_fund_inspiration_8014
			}
			if = {
				limit = { has_character_flag = had_event_fund_inspiration_8015 }
				remove_character_flag = had_event_fund_inspiration_8015
			}

			if = {
				limit = { has_character_flag = had_event_fund_inspiration_8017 }
				remove_character_flag = had_event_fund_inspiration_8017
			}
		}
	}
}


##################################################
# You funded an inspiration
# by Linnéa Thimrén and Bianca Savazzi
# 0001-1000
##################################################

# Fallback version - very generic
fund_inspiration.0001 = {
	type = character_event
	hidden = yes

	immediate = {
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		
		send_interface_toast = {
			title = fund_inspiration.0001.t
			left_icon = scope:inspiration_owner
			show_as_tooltip = {
				fund_inspiration_effect = yes
			}
		}
	}
}

#Fund Inspiration: Weapon - Choose your item
#By Bianca Savazzi
fund_inspiration.0011 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.0011.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	trigger = {
		scope:inspiration = {
			has_inspiration_type = weapon_inspiration
		}
		scope:inspiration_owner = { NOT = { exists = var:artifact_weapon_type } }
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		#Saving some scopes for the tooltips

		save_scope_as = actor
		scope:inspiration_owner = {
			assign_quirk_effect = yes
			save_scope_as = recipient
		}

	}

	# sword; close quarters to slash and pierce
	option = {
		name = fund_inspiration.0011.a

		scope:inspiration_owner = {
			random_list = { #What do they want to forge?
				10 = {
					desc = fund_inspiration.0011.tooltip_dagger
					set_variable = {
						name = artifact_weapon_type
						value = flag:artifact_weapon_type_dagger
					}
					custom_tooltip = fund_inspiration.0011.tooltip_dagger.tt
				}
				10 = {
					desc = fund_inspiration.0011.tooltip_sword
					set_variable = {
						name = artifact_weapon_type
						value = flag:artifact_weapon_type_sword
					}
					custom_tooltip = fund_inspiration.0011.tooltip_sword.tt
				}
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 25
				has_trait = brave
			}
		}
	}

	# axe or mace; blunt and smash
	option = {
		name = fund_inspiration.0011.b
		scope:inspiration_owner = {
			random_list = { #What do they want to forge?
				10 = {
					desc = fund_inspiration.0011.tooltip_axe
					set_variable = {
						name = artifact_weapon_type
						value = flag:artifact_weapon_type_axe
					}
					custom_tooltip = fund_inspiration.0011.tooltip_axe.tt
				}
				10 = {
					desc = fund_inspiration.0011.tooltip_hammer
					set_variable = {
						name = artifact_weapon_type
						value = flag:artifact_weapon_type_hammer
					}
					custom_tooltip = fund_inspiration.0011.tooltip_hammer.tt
				}
				10 = {
					desc = fund_inspiration.0011.tooltip_mace
					set_variable = {
						name = artifact_weapon_type
						value = flag:artifact_weapon_type_mace
					}
					custom_tooltip = fund_inspiration.0011.tooltip_mace.tt
				}
			}
		}
		ai_chance = {
			base = 0 # 50
			modifier = {
				add = 25
				has_trait = strong
			}
			modifier = {
				add = 25
				has_trait = berserker
			}
		}
	}

	# spear; create distance
	option = {
		name = fund_inspiration.0011.c
		scope:inspiration_owner = {
			random_list = { #What do they want to forge?
				10 = {
					desc = fund_inspiration.0011.tooltip_spear
					set_variable = {
						name = artifact_weapon_type
						value = flag:artifact_weapon_type_spear
					}
					custom_tooltip = fund_inspiration.0011.tooltip_spear.tt
				}
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 25
				has_trait = craven
			}
			modifier = {
				add = 25
				OR = {
					has_intrigue_lifestyle_trait_trigger = yes
 					has_lifestyle = intrigue_lifestyle
 				}
			}
		}
	}

	# bow
	option = {
		name = fund_inspiration.0011.d
		trigger = {
			scope:inspiration_owner = { has_character_modifier = local_artisan_modifier }
		}
		custom_tooltip = {
			text = fund_inspiration.0011.d.tt
			scope:inspiration_owner = {
				destroy_inspiration = inspiration
				create_inspiration = bow_inspiration
			}
			sponsor_inspiration = scope:inspiration_owner.inspiration
		}
		ai_chance = {
			base = 25
			modifier = {
				add = 50
				has_trait = lifestyle_hunter
			}
		}
	}

	# default option of "do what you want"
	option = {
		name = fund_inspiration.0031.f
		hidden_effect = { #If they haven't specified what they're gonna make we decide it here
			set_weapon_artifact_type_effect = {
				BASE_SCOPE = scope:inspiration_owner
				NO_TYPE = no
			}
		}
		custom_tooltip = fund_inspiration.they_decide_option_tt
		ai_chance = {
			base = 25
			modifier = {
				add = 25
				has_trait = arbitrary
			}
		}
	}
}

# Weapon - they know what they want to make
fund_inspiration.0012 = {
	hidden = yes

	trigger = {
		scope:inspiration = {
			has_inspiration_type = weapon_inspiration
			inspiration_owner = { #They know what weapon they want to make 
				exists = var:artifact_weapon_type
			}
		}
	}

	immediate = {
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		send_interface_toast = {
			title = fund_inspiration.0012.t
			left_icon = scope:inspiration_owner
			show_as_tooltip = {
				fund_inspiration_effect = yes
			}
		}
	}
}


# Armor - You can decide type of armor
scripted_trigger fund_inspiration_0021_option_mail_trigger = {
	NOT = { exists = scope:armor_type_mail_option }
}
scripted_trigger fund_inspiration_0021_option_plate_trigger = {
	NOT = { exists = scope:armor_type_plate_option }
}
scripted_trigger fund_inspiration_0021_option_scale_trigger = {
	NOT = { exists = scope:armor_type_scale_option }
}
scripted_trigger fund_inspiration_0021_option_lamellar_trigger = {
	NOT = { exists = scope:armor_type_lamellar_option }
}
scripted_trigger fund_inspiration_0021_option_laminar_trigger = {
	NOT = { exists = scope:armor_type_laminar_option }
}
scripted_trigger fund_inspiration_0021_option_brigandine_trigger = {
	NOT = { exists = scope:armor_type_brigandine_option }
}
scripted_effect fund_inspiration_0021_pick_options_to_show_effect = {
	#What options do we show?
	hidden_effect = {
		random_list = {
			60 = { #Fairly common everywhere
				trigger = {
					fund_inspiration_0021_option_mail_trigger = yes
				}
				artifact_armor_type_mail_modifier = yes
				save_scope_value_as = {
					name = armor_type_mail_option
					value = yes
				}
			}
			1 = { #Expensive
				trigger = {
					fund_inspiration_0021_option_plate_trigger = yes
					scope:inspiration_owner = {
						culture = { has_innovation = innovation_plate_armor }
					}
				}
				artifact_armor_type_plate_modifier = yes
				save_scope_value_as = {
					name = armor_type_plate_option
					value = yes
				}
			}
			60 = { #Fairly common everywhere
				trigger = {
					fund_inspiration_0021_option_scale_trigger = yes
				}
				artifact_armor_type_scale_modifier = yes
				save_scope_value_as = {
					name = armor_type_scale_option
					value = yes
				}
			}
			1 = { #Expensive
				trigger = {
					fund_inspiration_0021_option_lamellar_trigger = yes
				}
				artifact_armor_type_lamellar_modifier = yes
				save_scope_value_as = {
					name = armor_type_lamellar_option
					value = yes
				}
			}
			1 = {
				trigger = {
					fund_inspiration_0021_option_laminar_trigger = yes
				}
				artifact_armor_type_laminar_modifier = yes
				save_scope_value_as = {
					name = armor_type_laminar_option
					value = yes
				}
			}
			0 = {
				trigger = {
					fund_inspiration_0021_option_brigandine_trigger = yes
				}
				artifact_armor_type_brigandine_modifier = yes
				save_scope_value_as = {
					name = armor_type_brigandine_option
					value = yes
				}
			}
		}
	}
}

fund_inspiration.0021 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.0021.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	trigger = {
		scope:inspiration = {
			has_inspiration_type = armor_inspiration
			inspiration_owner = { #They haven't already decided what armor to make 
				NOT = { exists = var:artifact_armor_type }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		
		show_as_tooltip = {
			fund_inspiration_effect = yes
		}

		# What options should we show?
		fund_inspiration_0021_pick_options_to_show_effect = yes
		fund_inspiration_0021_pick_options_to_show_effect = yes
		fund_inspiration_0021_pick_options_to_show_effect = yes
	}

	#Chain mail
	option = {
		name = fund_inspiration.0021.mail
		trigger = {
			exists = scope:armor_type_mail_option
		}
		custom_tooltip = fund_inspiration.0021.mail.tt
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_armor_type
				value = flag:armor_type_mail
			}
		}
		ai_chance = {
			base = 10
			artifact_armor_type_mail_modifier = yes
		}
	}
	#Plate armor
	option = {
		name = fund_inspiration.0021.plate
		trigger = {
			exists = scope:armor_type_plate_option
		}
		custom_tooltip = fund_inspiration.0021.plate.tt
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_armor_type
				value = flag:armor_type_plate
			}
		}
		ai_chance = {
			base = 10
			artifact_armor_type_plate_modifier = yes
		}
	}
	#Scale armor
	option = {
		name = fund_inspiration.0021.scale
		trigger = {
			exists = scope:armor_type_scale_option
		}
		custom_tooltip = fund_inspiration.0021.scale.tt
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_armor_type
				value = flag:armor_type_scale
			}
		}
		ai_chance = {
			base = 10
			artifact_armor_type_scale_modifier = yes
		}
	}
	#Lamellar
	option = {
		name = fund_inspiration.0021.lamellar
		trigger = {
			exists = scope:armor_type_lamellar_option
		}
		custom_tooltip = fund_inspiration.0021.lamellar.tt
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_armor_type
				value = flag:armor_type_lamellar
			}
		}
		ai_chance = {
			base = 10
			artifact_armor_type_lamellar_modifier = yes
		}
	}
	#Laminar
	option = {
		name = fund_inspiration.0021.laminar
		trigger = {
			exists = scope:armor_type_laminar_option
		}
		custom_tooltip = fund_inspiration.0021.laminar.tt
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_armor_type
				value = flag:armor_type_laminar
			}
		}
		ai_chance = {
			base = 10
			artifact_armor_type_laminar_modifier = yes
		}
	}
	#Brigandine
	option = {
		name = fund_inspiration.0021.brigandine
		trigger = {
			exists = scope:armor_type_brigandine_option
		}
		custom_tooltip = fund_inspiration.0021.brigandine.tt
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_armor_type
				value = flag:armor_type_brigandine
			}
		}
		ai_chance = {
			base = 10
			artifact_armor_type_brigandine_modifier = yes
		}
	}
	option = {
		name = fund_inspiration.0031.f
		custom_tooltip = fund_inspiration.they_decide_option_tt
		set_armor_artifact_type_effect = {
			BASE_SCOPE = scope:inspiration_owner
			NO_TYPE = no
		}
		ai_chance = {
			base = 0
		}
	}
}

# Armor - they know what they want to make
fund_inspiration.0022 = {
	hidden = yes

	trigger = {
		scope:inspiration = {
			has_inspiration_type = armor_inspiration
			inspiration_owner = { #They know what armor they want to make 
				exists = var:artifact_armor_type
			}
		}
	}

	immediate = {
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		send_interface_toast = {
			title = fund_inspiration.0022.t
			left_icon = scope:inspiration_owner
			show_as_tooltip = {
				fund_inspiration_effect = yes
			}
		}
	}
}



# Book - choose subject
# by Linnéa Thimrén
scripted_trigger fund_inspiration_0031_title_based_option_trigger = {

	OR = {
		AND = {
			exists = global_var:flag_restored_roman_empire
			global_var:flag_restored_roman_empire = root
			NOT = { exists = scope:book_topic_restoration }
		}
		AND = {
			exists = global_var:flag_restored_dumnonia
			global_var:flag_restored_dumnonia = root
			NOT = { exists = scope:book_topic_restoration }
		}
		AND = {
			exists = global_var:flag_reformed_carolingian_empire
			global_var:flag_reformed_carolingian_empire = root
			NOT = { exists = scope:book_topic_restoration }
		}
		AND = {
			exists = global_var:restore_holy_roman_empire_decision
			global_var:restore_holy_roman_empire_decision = root
			NOT = { exists = scope:book_topic_restoration }
		}
		AND = {
			exists = global_var:unite_the_spanish_thrones_decision
			global_var:unite_the_spanish_thrones_decision = root
			exists = global_var:unite_the_spanish_thrones_decision_title
			NOT = { exists = scope:book_topic_unification }
		}
		AND = {
			exists = global_var:unite_the_slavs_decision
			global_var:unite_the_slavs_decision = root
			NOT = { exists = scope:book_topic_unification }
		}
		AND = {
			exists = global_var:unite_the_southern_slavs_decision
			global_var:unite_the_southern_slavs_decision = root
			exists = global_var:unite_the_southern_slavs_decision_title
			NOT = { exists = scope:book_topic_unification }
		}
		AND = {
			exists = global_var:unite_the_western_slavs_decision
			global_var:unite_the_western_slavs_decision = root
			NOT = { exists = scope:book_topic_unification }
		}
		AND = {
			exists = global_var:flag_unified_burgundy_kingdom
			global_var:flag_unified_burgundy_kingdom = root
			NOT = { exists = scope:book_topic_unification }
		}
		AND = {
			exists = global_var:flag_unified_italian_empire
			global_var:flag_unified_italian_empire = root
			NOT = { exists = scope:book_topic_unification }
		}
		AND = {
			exists = global_var:form_portugal_decision
			global_var:form_portugal_decision = root
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:flag_founded_kingdom_of_bosnia
			global_var:flag_founded_kingdom_of_bosnia = root
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:flag_created_armenian_empire
			global_var:flag_created_armenian_empire = root
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:flag_formed_rum_sultanate
			global_var:flag_formed_rum_sultanate = root
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:create_israel_kingdom
			global_var:create_israel_kingdom = root
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:flag_created_outremer_empire
			global_var:flag_created_outremer_empire = root
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:flag_formed_switzerland_kingdom
			global_var:flag_formed_switzerland_kingdom = root
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:flag_formed_austria_kingdom
			global_var:flag_formed_austria_kingdom = root
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:flag_formed_kingdom_of_aragon
			global_var:flag_formed_kingdom_of_aragon = root
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:form_toledo_decision
			global_var:form_toledo_decision = root
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:found_kingdom_decision
			global_var:found_kingdom_decision = root
			exists = global_var:found_kingdom_decision_kingdom
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:found_empire_decision
			global_var:found_empire_decision = root
			exists = global_var:found_empire_decision_empire
			NOT = { exists = scope:book_topic_creation }
		}
		AND = {
			exists = global_var:flag_restored_old_vasconia
			global_var:flag_restored_old_vasconia = root
			NOT = { exists = scope:book_topic_restoration }
		}
	}
}

scripted_trigger fund_inspiration_0031_dynasty_option_trigger = {
	NOT = { exists = scope:dynasty_option }
	exists = dynasty
}

scripted_trigger fund_inspiration_0031_education_option_trigger = {
	NOT = { exists = scope:education_option }
	OR = {
		has_education_martial_trigger = yes
		has_education_diplomacy_trigger = yes
		has_education_stewardship_trigger = yes
		has_education_learning_trigger = yes
		has_education_intrigue_trigger = yes
	}
}

scripted_trigger fund_inspiration_0031_lifestyle_option_trigger = {
	NOT = { exists = scope:lifestyle_option }
	OR = {
		has_lifestyle_trait = yes
		is_cannibal_trigger = yes
		is_witch_trigger = yes
		is_deviant_trigger = yes
		has_trait = lunatic
	}
}

scripted_trigger fund_inspiration_0031_focus_option_trigger = {
	NOT = { exists = scope:focus_option }
	OR = {
		has_focus_martial = yes
		has_focus_diplomacy = yes
		has_focus_stewardship = yes
		has_focus_intrigue = yes
		has_focus_learning = yes
	}
}

scripted_trigger fund_inspiration_0031_relationship_option_trigger = {
	NOT = { exists = scope:relationship_option }
	OR = {
		any_relation = {
			type = soulmate
			NOT = { this = scope:inspiration_owner }
		}
		any_relation = {
			type = nemesis
			NOT = { this = scope:inspiration_owner }
		}
	}
}

scripted_trigger fund_inspiration_0031_mystical_animal_option_trigger = {
	NOT = { exists = scope:mystical_animal_option }
	has_character_modifier = hunt_mystical_animal_modifier
	exists = var:hunted_mystical_animal
}

scripted_trigger fund_inspiration_0031_pet_option_trigger = {
	NOT = { exists = scope:pet_option }
	OR = { #You must have named them
		AND = {
			any_owned_story = {
				story_type = story_cycle_pet_cat
			}
			exists = var:story_cycle_cat_name
		}
		AND = {
			any_owned_story = {
				story_type = story_cycle_pet_dog
			}
			exists = var:story_cycle_dog_name
		}
	}
	calc_true_if = {
		amount < 3
		fund_inspiration_0031_title_based_option_trigger = yes
		fund_inspiration_0031_dynasty_option_trigger = yes
		fund_inspiration_0031_education_option_trigger = yes
		fund_inspiration_0031_lifestyle_option_trigger = yes
		fund_inspiration_0031_focus_option_trigger = yes
		fund_inspiration_0031_relationship_option_trigger = yes
		fund_inspiration_0031_mystical_animal_option_trigger = yes
	}
}

scripted_trigger fund_inspiration_0031_skill_option_trigger = {
	NOT = { exists = scope:skill_option }
	calc_true_if = {
		amount < 3
		fund_inspiration_0031_title_based_option_trigger = yes
		fund_inspiration_0031_dynasty_option_trigger = yes
		fund_inspiration_0031_education_option_trigger = yes
		fund_inspiration_0031_lifestyle_option_trigger = yes
		fund_inspiration_0031_focus_option_trigger = yes
		fund_inspiration_0031_relationship_option_trigger = yes
		fund_inspiration_0031_mystical_animal_option_trigger = yes
		fund_inspiration_0031_pet_option_trigger = yes
	}
}

scripted_effect fund_inspiration_0031_pick_options_to_show_effect = {
	#What options should we show?
	hidden_effect = {
		random_list = {
			800 = { # Have I ever restored/unified/formed/created/founded a kingdom/empire/etc.?
				trigger = {
					fund_inspiration_0031_title_based_option_trigger = yes
				}
				if = {
					limit = {
						AND = {
							exists = global_var:flag_restored_roman_empire
							global_var:flag_restored_roman_empire = root
						}
						NOT = { exists = scope:book_topic_restoration }
					}
					save_scope_value_as = {
						name = book_topic_restoration
						value = yes
					}
					title:e_roman_empire = {
						save_scope_as = restored_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_restored_dumnonia
							global_var:flag_restored_dumnonia = root
						}
						NOT = { exists = scope:book_topic_restoration }
					}
					save_scope_value_as = {
						name = book_topic_restoration
						value = yes
					}
					title:k_cornwall = {
						save_scope_as = restored_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_reformed_carolingian_empire
							global_var:flag_reformed_carolingian_empire = root
						}
						NOT = { exists = scope:book_topic_restoration }
					}
					save_scope_value_as = {
						name = book_topic_restoration
						value = yes
					}
					title:e_france = {
						save_scope_as = restored_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:restore_holy_roman_empire_decision
							global_var:restore_holy_roman_empire_decision = root
						}
						NOT = { exists = scope:book_topic_restoration }
					}
					save_scope_value_as = {
						name = book_topic_restoration
						value = yes
					}
					title:e_hre = {
						save_scope_as = restored_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:unite_the_spanish_thrones_decision
							global_var:unite_the_spanish_thrones_decision = root
							exists = global_var:unite_the_spanish_thrones_decision_title
						}
						NOT = { exists = scope:book_topic_unification }
					}
					save_scope_value_as = {
						name = book_topic_unification
						value = yes
					}
					global_var:unite_the_spanish_thrones_decision_title = {
						save_scope_as = united_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:unite_the_slavs_decision
							global_var:unite_the_slavs_decision = root
						}
						NOT = { exists = scope:book_topic_unification }
					}
					save_scope_value_as = {
						name = book_topic_unification
						value = yes
					}
					title:e_slavia = {
						save_scope_as = united_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:unite_the_southern_slavs_decision
							global_var:unite_the_southern_slavs_decision = root
							exists = global_var:unite_the_southern_slavs_decision_title
						}
						NOT = { exists = scope:book_topic_unification }
					}
					save_scope_value_as = {
						name = book_topic_unification
						value = yes
					}
					global_var:unite_the_southern_slavs_decision_title = {
						save_scope_as = united_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:unite_the_western_slavs_decision
							global_var:unite_the_western_slavs_decision = root
							exists = global_var:unite_the_western_slavs_decision_title
						}
						NOT = { exists = scope:book_topic_unification }
					}
					save_scope_value_as = {
						name = book_topic_unification
						value = yes
					}
					global_var:unite_the_western_slavs_decision_title = {
						save_scope_as = united_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_unified_burgundy_kingdom
							global_var:flag_unified_burgundy_kingdom = root
						}
						NOT = { exists = scope:book_topic_unification }
					}
					save_scope_value_as = {
						name = book_topic_unification
						value = yes
					}
					title:k_burgundy = {
						save_scope_as = united_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_unified_italian_empire
							global_var:flag_unified_italian_empire = root
						}
						NOT = { exists = scope:book_topic_unification }
					}
					save_scope_value_as = {
						name = book_topic_unification
						value = yes
					}
					title:e_italy = {
						save_scope_as = united_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:form_portugal_decision
							global_var:form_portugal_decision = root
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					title:k_portugal = {
						save_scope_as = created_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_founded_kingdom_of_bosnia
							global_var:flag_founded_kingdom_of_bosnia = root
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					title:k_bosnia = {
						save_scope_as = created_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_created_armenian_empire
							global_var:flag_created_armenian_empire = root
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					title:e_armenia = {
						save_scope_as = created_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_formed_rum_sultanate
							global_var:flag_formed_rum_sultanate = root
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					title:k_rum = {
						save_scope_as = created_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:create_israel_kingdom
							global_var:create_israel_kingdom = root
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					title:k_israel = {
						save_scope_as = created_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_created_outremer_empire
							global_var:flag_created_outremer_empire = root
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					title:e_outremer = {
						save_scope_as = created_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_formed_switzerland_kingdom
							global_var:flag_formed_switzerland_kingdom = root
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					title:k_switzerland = {
						save_scope_as = created_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_formed_austria_kingdom
							global_var:flag_formed_austria_kingdom = root
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					title:k_austria = {
						save_scope_as = created_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:flag_formed_kingdom_of_aragon
							global_var:flag_formed_kingdom_of_aragon = root
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					title:k_aragon = {
						save_scope_as = created_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:found_kingdom_decision
							global_var:found_kingdom_decision = root
							exists =  global_var:found_kingdom_decision_kingdom
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					global_var:found_kingdom_decision_kingdom = {
						save_scope_as = created_title
					}
				}
				else_if = {
					limit = {
						AND = {
							exists = global_var:found_empire_decision
							global_var:found_empire_decision = root
							exists =  global_var:found_empire_decision_empire
						}
						NOT = { exists = scope:book_topic_creation }
					}
					save_scope_value_as = {
						name = book_topic_creation
						value = yes
					}
					global_var:found_empire_decision_empire = {
						save_scope_as = created_title
					}
				}
			}
			5 = { # Dynasty
				trigger = {
					fund_inspiration_0031_dynasty_option_trigger = yes
				}
				save_scope_value_as = {
					name = dynasty_option
					value = yes
				}
			}
			10 = { # education trait
				trigger = {
					fund_inspiration_0031_education_option_trigger = yes
				}
				save_scope_value_as = {
					name = education_option
					value = yes
				}
			}
			10 = { # lifestyle/misc stuff
				trigger = {
					fund_inspiration_0031_lifestyle_option_trigger = yes
				}
				save_scope_value_as = {
					name = lifestyle_option
					value = yes
				}
				random_list = { #What topic do we offer you?
					10 = {
						trigger = { has_trait = lifestyle_reveler }
						save_scope_value_as = {
							name = lifestyle_option_reveler
							value = yes
						}
					}
					10 = {
						trigger = { has_trait = lifestyle_blademaster }
						save_scope_value_as = {
							name = lifestyle_option_blademaster
							value = yes
						}
					}
					10 = {
						trigger = { has_trait = lifestyle_hunter }
						save_scope_value_as = {
							name = lifestyle_option_hunter
							value = yes
						}
					}
					10 = {
						trigger = { has_trait = lifestyle_mystic }
						save_scope_value_as = {
							name = lifestyle_option_mystic
							value = yes
						}
					}
					10 = {
						trigger = { has_trait = lifestyle_herbalist }
						save_scope_value_as = {
							name = lifestyle_option_herbalist
							value = yes
						}
					}
					10 = {
						trigger = { has_trait = lifestyle_physician }
						save_scope_value_as = {
							name = lifestyle_option_physician
							value = yes
						}
					}
					10 = {
						trigger = { is_cannibal_trigger = yes }
						save_scope_value_as = {
							name = lifestyle_option_cannibal
							value = yes
						}
					}
					10 = {
						trigger = { is_witch_trigger = yes }
						save_scope_value_as = {
							name = lifestyle_option_witch
							value = yes
						}
					}
					10 = {
						trigger = { is_deviant_trigger = yes }
						save_scope_value_as = {
							name = lifestyle_option_deviant
							value = yes
						}
					}
					10 = {
						trigger = { has_trait = lunatic }
						save_scope_value_as = {
							name = lifestyle_option_lunatic
							value = yes
						}
					}
					10 = {
						trigger = { has_trait = torturer }
						save_scope_value_as = {
							name = lifestyle_option_torturer
							value = yes
						}
					}
				}
			}
			10 = { # focus
				trigger = {
					fund_inspiration_0031_focus_option_trigger = yes
				}
				save_scope_value_as = {
					name = focus_option
					value = yes
				}
			}
			5 = { # relationship
				trigger = {
					fund_inspiration_0031_relationship_option_trigger = yes
				}
				save_scope_value_as = {
					name = relationship_option
					value = yes
				}
				if = {
					limit = {
						any_relation = {
							type = soulmate
							NOT = { this = scope:inspiration_owner }
						}
					}
					random_relation = {
						type = soulmate
						limit = {
							NOT = { this = scope:inspiration_owner }
						}
						save_scope_as = relationship_scope
					}
					save_scope_value_as = {
						name = relationship_option_soulmate
						value = yes
					}
				}
				else_if = {
					limit = {
						any_relation = {
							type = nemesis
							NOT = { this = scope:inspiration_owner }
						}
					}
					random_relation = {
						type = nemesis
						limit = {
							NOT = { this = scope:inspiration_owner }
						}
						save_scope_as = relationship_scope
					}
					save_scope_value_as = {
						name = relationship_option_nemesis
						value = yes
					}
				}
			}
			50 = { # mystical animal
				trigger = {
					fund_inspiration_0031_mystical_animal_option_trigger = yes
				}
				save_scope_value_as = {
					name = mystical_animal_option
					value = yes
				}
				set_variable = {
					name = animal_type
					value = root.var:hunted_mystical_animal
				}
			}
			5 = { # pet (only if we don't have enough options already)
				trigger = {
					fund_inspiration_0031_pet_option_trigger = yes
				}
				save_scope_value_as = {
					name = pet_option
					value = yes
				}
				random_list = {
					50 = {
						trigger = {
							any_owned_story = {
								story_type = story_cycle_pet_cat
							}
							exists = var:story_cycle_cat_name
						}
						save_scope_value_as = {
							name = pet_option_cat
							value = yes
						}
					}
					50 = {
						trigger = {
							any_owned_story = {
								story_type = story_cycle_pet_dog
							}
						}
						save_scope_value_as = {
							name = pet_option_dog
							value = yes
						}
					}
				}
			}
			1 = { # skill (only if we don't have enough options already)
				trigger = {
					fund_inspiration_0031_skill_option_trigger = yes
				}
				save_scope_value_as = {
					name = skill_option
					value = yes
				}
				if = {
					limit = {
						highest_skill = martial
						NOT = { has_education_martial_trigger = yes }
						trigger_if = {
							limit = {
								exists = scope:focus_option
							}
							has_focus_martial = no
						}
					}
					save_scope_value_as = {
						name = skill_option_martial
						value = yes
					}
				}
				else_if = {
					limit = {
						highest_skill = diplomacy
						NOT = { has_education_diplomacy_trigger = yes }
						trigger_if = {
							limit = {
								exists = scope:focus_option
							}
							has_focus_diplomacy = no
						}
					}
					save_scope_value_as = {
						name = skill_option_diplomacy
						value = yes
					}
				}
				else_if = {
					limit = {
						highest_skill = stewardship
						NOT = { has_education_stewardship_trigger = yes }
						trigger_if = {
							limit = {
								exists = scope:focus_option
							}
							has_focus_stewardship = no
						}
					}
					save_scope_value_as = {
						name = skill_option_stewardship
						value = yes
					}
				}
				else_if = {
					limit = {
						highest_skill = intrigue
						NOT = { has_education_intrigue_trigger = yes }
						trigger_if = {
							limit = {
								exists = scope:focus_option
							}
							has_focus_intrigue = no
						}
					}
					save_scope_value_as = {
						name = skill_option_intrigue
						value = yes
					}
				}
				else_if = {
					limit = {
						highest_skill = learning
						NOT = { has_education_learning_trigger = yes }
						trigger_if = {
							limit = {
								exists = scope:focus_option
							}
							has_focus_learning = no
						}
					}
					save_scope_value_as = {
						name = skill_option_learning
						value = yes
					}
				}
				else = { #Fallback
					random_list = {
						1 = {
							trigger = {
								NOT = { has_education_martial_trigger = yes }
								trigger_if = {
									limit = {
										exists = scope:focus_option
									}
									has_focus_martial = no
								}
								OR = { #Cannot be the lowest skill
									martial > diplomacy
									martial > stewardship
									martial > intrigue
									martial > learning
								}
							}
							compare_modifier = {
								value = martial
								multiplier = 4
							}
							save_scope_value_as = {
								name = skill_option_martial
								value = yes
							}
						}
						1 = {
							trigger = {
								NOT = { has_education_diplomacy_trigger = yes }
								trigger_if = {
									limit = {
										exists = scope:focus_option
									}
									has_focus_diplomacy = no
								}
								OR = { #Cannot be the lowest skill
									diplomacy > martial
									diplomacy > stewardship
									diplomacy > intrigue
									diplomacy > learning
								}
							}
							compare_modifier = {
								value = diplomacy
								multiplier = 4
							}
							save_scope_value_as = {
								name = skill_option_diplomacy
								value = yes
							}
						}
						1 = {
							trigger = {
								NOT = { has_education_stewardship_trigger = yes }
								trigger_if = {
									limit = {
										exists = scope:focus_option
									}
									has_focus_stewardship = no
								}
								OR = { #Cannot be the lowest skill
									stewardship > martial
									stewardship > diplomacy
									stewardship > intrigue
									stewardship > learning
								}
							}
							compare_modifier = {
								value = stewardship
								multiplier = 4
							}
							save_scope_value_as = {
								name = skill_option_stewardship
								value = yes
							}
						}
						1 = {
							trigger = {
								NOT = { has_education_intrigue_trigger = yes }
								trigger_if = {
									limit = {
										exists = scope:focus_option
									}
									has_focus_intrigue = no
								}
								OR = { #Cannot be the lowest skill
									intrigue > martial
									intrigue > diplomacy
									intrigue > stewardship
									intrigue > learning
								}
							}
							compare_modifier = {
								value = intrigue
								multiplier = 4
							}
							save_scope_value_as = {
								name = skill_option_intrigue
								value = yes
							}
						}
						1 = {
							trigger = {
								NOT = { has_education_learning_trigger = yes }
								trigger_if = {
									limit = {
										exists = scope:focus_option
									}
									has_focus_learning = no
								}
								OR = { #Cannot be the lowest skill
									learning > martial
									learning > diplomacy
									learning > stewardship
									learning > intrigue
								}
							}
							compare_modifier = {
								value = learning
								multiplier = 4
							}
							save_scope_value_as = {
								name = skill_option_learning
								value = yes
							}
						}
					}
				}
			}
		}
	}
}

fund_inspiration.0031 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.0031.desc
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_owner
		triggered_animation = {
			trigger = {
				scope:inspiration = {
					has_inspiration_type = book_inspiration
				}
			}
			animation = writing
		}
		animation = personality_honorable
	}
	right_portrait = {
		trigger = {
			exists = scope:relationship_scope
		}
		character = scope:relationship_scope
	}

	trigger = {
		scope:inspiration = {
			has_inspiration_type = book_inspiration
			inspiration_owner = { #They haven't already decided what to write about 
				NOT = { exists = var:book_subject }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
			assign_quirk_effect = yes
		}

		# We save a subject here so that the inspiration owner can come with a suggestion. It is not saved however.
		set_book_subject_effect = {
			BASE_SCOPE = scope:inspiration_owner
			NO_SUBJECT = no
		}
		scope:inspiration_owner = {
			if = { #To avoid tooltip errors
				limit = {
					exists = var:book_subject
				}
				var:book_subject = {
					save_scope_as = subject
				}
			}
			remove_variable = book_subject
		}
		
		show_as_tooltip = {
			fund_inspiration_effect = yes
		}

		# What options should we show?
		fund_inspiration_0031_pick_options_to_show_effect = yes
		fund_inspiration_0031_pick_options_to_show_effect = yes
		fund_inspiration_0031_pick_options_to_show_effect = yes
	}

	option = { #Education
		name = fund_inspiration.0031.education
		trigger = {
			exists = scope:education_option
		}
		trait = education_martial_1
		trait = education_martial_2
		trait = education_martial_3
		trait = education_martial_4
		trait = education_martial_5
		trait = education_diplomacy_1
		trait = education_diplomacy_2
		trait = education_diplomacy_3
		trait = education_diplomacy_4
		trait = education_diplomacy_5
		trait = education_learning_1
		trait = education_learning_2
		trait = education_learning_3
		trait = education_learning_4
		trait = education_learning_5
		trait = education_stewardship_1
		trait = education_stewardship_2
		trait = education_stewardship_3
		trait = education_stewardship_4
		trait = education_stewardship_5
		trait = education_intrigue_1
		trait = education_intrigue_2
		trait = education_intrigue_3
		trait = education_intrigue_4
		trait = education_intrigue_5
		if = {
			limit = {
				has_education_martial_trigger = yes
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:martial
				}
			}
		}
		else_if = {
			limit = {
				has_education_diplomacy_trigger = yes
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:diplomacy
				}
			}
		}
		else_if = {
			limit = {
				has_education_stewardship_trigger = yes
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:stewardship
				}
			}
		}
		else_if = {
			limit = {
				has_education_learning_trigger = yes
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:learning
				}
			}
		}
		else_if = {
			limit = {
				has_education_intrigue_trigger = yes
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:intrigue
				}
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt

		ai_chance = {
			base = 50
			modifier = {
				add = 25
				has_education_martial_trigger = yes
				martial > high_skill_rating
			}
			modifier = {
				add = 25
				has_education_diplomacy_trigger = yes
				diplomacy > high_skill_rating
			}
			modifier = {
				add = 25
				has_education_stewardship_trigger = yes
				stewardship > high_skill_rating
			}
			modifier = {
				add = 25
				has_education_learning_trigger = yes
				learning > high_skill_rating
			}
			modifier = {
				add = 25
				has_education_intrigue_trigger = yes
				intrigue > high_skill_rating
			}
		}
	}

	option = { #lifestyle/misc stuff
		name = {
			trigger = { exists = scope:lifestyle_option_reveler }
			text = fund_inspiration.0031.lifestyle_reveler
		}
		name = {
			trigger = { exists = scope:lifestyle_option_blademaster }
			text = fund_inspiration.0031.lifestyle_blademaster
		}
		name = {
			trigger = { exists = scope:lifestyle_option_hunter }
			text = fund_inspiration.0031.lifestyle_hunter
		}
		name = {
			trigger = { exists = scope:lifestyle_option_mystic }
			text = fund_inspiration.0031.lifestyle_mystic
		}
		name = {
			trigger = { exists = scope:lifestyle_option_torturer }
			text = fund_inspiration.0031.lifestyle_torturer
		}
		name = {
			trigger = { exists = scope:lifestyle_option_herbalist }
			text = fund_inspiration.0031.lifestyle_herbalist
		}
		name = {
			trigger = { exists = scope:lifestyle_option_physician }
			text = fund_inspiration.0031.lifestyle_physician
		}
		name = {
			trigger = { exists = scope:lifestyle_option_cannibal }
			text = fund_inspiration.0031.lifestyle_cannibal
		}
		name = {
			trigger = { exists = scope:lifestyle_option_witch }
			text = fund_inspiration.0031.lifestyle_witch
		}
		name = {
			trigger = { exists = scope:lifestyle_option_deviant }
			text = fund_inspiration.0031.lifestyle_deviant
		}
		name = {
			trigger = { exists = scope:lifestyle_option_lunatic }
			text = fund_inspiration.0031.lifestyle_lunatic
		}
		trigger = {
			exists = scope:lifestyle_option
		}
		trait = lifestyle_reveler
		trait = lifestyle_blademaster
		trait = lifestyle_hunter
		trait = lifestyle_mystic
		trait = lifestyle_herbalist
		trait = torturer
		trait = lifestyle_physician
		trait = cannibal
		trait = witch
		trait = deviant
		trait = lunatic_1
		trait = lunatic_genetic
		if = {
			limit = {
				exists = scope:lifestyle_option_reveler
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:reveler
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:lifestyle_option_blademaster
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:blademaster
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:lifestyle_option_hunter
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:hunter
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:lifestyle_option_torturer
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:torturer
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:lifestyle_option_mystic
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:mystic
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:lifestyle_option_herbalist
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:herbalist
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:lifestyle_option_physician
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:medicine
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:lifestyle_option_cannibal
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:cannibal
				}
				# Can either be about recipes or more general about the consumption of human flesh
				hidden_effect = {
					random_list = {
						50 = { #Undecided, for now
						}
						50 = {
							set_variable = {
								name = book_topic
								value = flag:cannibal_recipes
							}
						}
					}
				}

				#opinion hit for the more _out there_ choices
				if = {
					limit = {
						NOT = { is_cannibal_trigger = yes }
					}
					add_opinion = {
						target = root
						modifier = scared_opinion
						opinion = -20
					}
				}
			}
			#reveal secret to the writer if there is one
			if = {
				limit = {
					any_secret = {
						secret_type = secret_cannibal
						NOT = {
							any_secret_knower = { this = scope:inspiration_owner }
						} 
					}
				}
				random_secret = {
					limit = {
						secret_type = secret_cannibal
						NOT = {
							any_secret_knower = { this = scope:inspiration_owner }
						} 
					}
					reveal_to = scope:inspiration_owner
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:lifestyle_option_witch
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:witch
				}
				set_variable = {
					name = book_subject_witch_scope
					value = root
				}
				#opinion hit for the more _out there_ choices
				if = {
					limit = {
						NOT = { is_witch_trigger = yes }
						trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = root }
					}
					if = {
						limit = {
							OR = {
								has_trait = zealous
								piety_level >= high_piety_level
								has_trait = faith_warrior
							}
						}
						add_opinion = {
							target = root
							modifier = impious_opinion
							opinion = -30
						}
					}
					else = {
						add_opinion = {
							target = root
							modifier = scared_opinion
							opinion = -15
						}
					}
				}
			}
			#reveal secret to the writer if there is one
			if = {
				limit = {
					any_secret = {
						secret_type = secret_witch
						NOT = {
							any_secret_knower = { this = scope:inspiration_owner }
						} 
					}
				}
				random_secret = {
					limit = {
						secret_type = secret_witch
						NOT = {
							any_secret_knower = { this = scope:inspiration_owner }
						} 
					}
					reveal_to = scope:inspiration_owner
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:lifestyle_option_deviant
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:deviant
				}
				#opinion hit for the more _out there_ choices
				if = {
					limit = {
						NOT = { is_deviant_trigger = yes }
					}
					add_opinion = {
						target = root
						modifier = disgusted_opinion
						opinion = -20
					}
				}
			}
			#reveal secret to the writer if there is one
			if = {
				limit = {
					any_secret = {
						secret_type = secret_deviant
						NOT = {
							any_secret_knower = { this = scope:inspiration_owner }
						} 
					}
				}
				random_secret = {
					limit = {
						secret_type = secret_deviant
						NOT = {
							any_secret_knower = { this = scope:inspiration_owner }
						} 
					}
					reveal_to = scope:inspiration_owner
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:lifestyle_option_lunatic
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:lunatic
				}
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt

		ai_chance = {
			base = 75
			modifier = { # If it's hidden secrets it's rare that they write about it
				add = -70
				exists = scope:lifestyle_option_witch
				NOT = { has_trait = witch }
				trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = root }
			}
			modifier = { # If it's hidden secrets it's rare that they write about it
				add = -70
				exists = scope:lifestyle_option_deviant
				NOT = { has_trait = deviant }
				trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = root }
			}
			modifier = { # If it's hidden secrets it's rare that they write about it
				add = -70
				exists = scope:lifestyle_option_cannibal
				NOT = { has_trait = cannibal }
				trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = root }
			}
			modifier = { #However, the might if they're arrogant
				add = 50
				has_trait = arrogant
			}
			ai_value_modifier = {
				ai_boldness = 0.25
			}
		}
	}

	option = { #Lifestyle Focus
		name = fund_inspiration.0031.focus
		trigger = {
			exists = scope:focus_option
		}
		if = {
			limit = {
				has_focus_martial = yes
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:martial
				}
			}
		}
		else_if = {
			limit = {
				has_focus_diplomacy = yes
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:diplomacy
				}
			}
		}
		else_if = {
			limit = {
				has_focus_stewardship = yes
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:stewardship
				}
			}
		}
		else_if = {
			limit = {
				has_focus_learning = yes
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:learning
				}
			}
		}
		else_if = {
			limit = {
				has_focus_intrigue = yes
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:intrigue
				}
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		ai_chance = {
			base = 50
			modifier = {
				add = 25
				has_focus_martial = yes
				martial > high_skill_rating
			}
			modifier = {
				add = 25
				has_focus_diplomacy = yes
				diplomacy > high_skill_rating
			}
			modifier = {
				add = 25
				has_focus_stewardship = yes
				stewardship > high_skill_rating
			}
			modifier = {
				add = 25
				has_focus_learning = yes
				learning > high_skill_rating
			}
			modifier = {
				add = 25
				has_focus_intrigue = yes
				intrigue > high_skill_rating
			}
		}
	}

	option = { #Skill
		name = {
			trigger = { exists = scope:skill_option_martial }
			text = fund_inspiration.0031.skill_option_martial
		}
		name = {
			trigger = { exists = scope:skill_option_diplomacy }
			text = fund_inspiration.0031.skill_option_diplomacy
		}
		name = {
			trigger = { exists = scope:skill_option_stewardship }
			text = fund_inspiration.0031.skill_option_stewardship
		}
		name = {
			trigger = { exists = scope:skill_option_learning }
			text = fund_inspiration.0031.skill_option_learning
		}
		name = {
			trigger = { exists = scope:skill_option_intrigue }
			text = fund_inspiration.0031.skill_option_intrigue
		}
		trigger = {
			exists = scope:skill_option
		}
		if = {
			limit = {
				exists = scope:skill_option_martial
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:martial
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:skill_option_diplomacy
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:diplomacy
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:skill_option_stewardship
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:stewardship
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:skill_option_learning
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:learning
				}
			}
		}
		else_if = {
			limit = {
				exists = scope:skill_option_intrigue
			}
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = flag:intrigue
				}
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		ai_chance = { # Kinda a fallback option, so we don't want the AI choosing this too often
			base = 10
		}
	}

	option = { #Relationship
		name = {
			trigger = { exists = scope:relationship_option_soulmate }
			text = fund_inspiration.0031.relationship_soulmate
		}
		name = {
			trigger = { exists = scope:relationship_option_nemesis }
			text = fund_inspiration.0031.relationship_nemesis
		}
		trigger = {
			exists = scope:relationship_option
			exists = scope:relationship_scope
		}
		scope:inspiration_owner = {
			set_variable = {
				name = book_subject
				value = flag:relationship
			}
			if = {
				limit = {
					exists = scope:relationship_option_soulmate
				}
				set_variable = {
					name = book_topic
					value = flag:soulmate
				}
			}
			else = {
				set_variable = {
					name = book_topic
					value = flag:nemesis
				}
			}
			set_variable = {
				name = book_topic_relationship
				value = scope:relationship_scope
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		ai_chance = {
			base = 0
			#My opinion of them
			opinion_modifier = {
				trigger = {
					exists = scope:relationship_option_soulmate
				}
				opinion_target = scope:relationship_scope
			}
			opinion_modifier = {
				trigger = {
					exists = scope:relationship_option_nemesis
				}
				opinion_target = scope:relationship_scope
				multiplier = -0.25
			}
			#Their opinion of me
			opinion_modifier = {
				trigger = {
					exists = scope:relationship_option_soulmate
				}
				who = scope:relationship_scope
				opinion_target = root
			}
			opinion_modifier = {
				trigger = {
					exists = scope:relationship_option_nemesis
				}
				who = scope:relationship_scope
				opinion_target = root
				multiplier = -0.25
			}

			ai_value_modifier = {
				trigger = {
					exists = scope:relationship_option_nemesis
				}
				ai_vengefulness = 0.5
			}
		}
	}

	option = { #Dynasty
		name = fund_inspiration.0031.dynasty
		trigger = {
			exists = scope:dynasty_option
		}
		scope:inspiration_owner = {
			set_variable = {
				name = book_subject
				value = flag:dynasty
			}
			set_variable = {
				name = book_topic
				value = flag:dynasty
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		ai_chance = {
			base = 25
			modifier = {
				add = 50
				has_trait = arrogant
			}
			modifier = {
				add = 25
				has_trait = ambitious
			}
			modifier = { #more likely if you have a _cool_ dynasty
				add = 25
				dynasty = {
					dynasty_prestige >= medium_dynasty_prestige_value
				}
			}
			ai_value_modifier = {
				ai_greed = 0.25
			}
		}
	}

	option = { #Mystical animal
		name = fund_inspiration.0031.mystical_animal
		trigger = {
			exists = scope:mystical_animal_option
			exists = var:animal_type
		}
		scope:inspiration_owner = {
			set_variable = {
				name = book_subject
				value = flag:mystical_animal
			}
		}
		remove_variable = animal_type
		custom_tooltip = fund_inspiration.you_decide_option_tt
		ai_chance = {
			base = 10 #Not common if you don't have the personality for it
			modifier = {
				add = 50
				has_trait = lifestyle_hunter
			}
			modifier = {
				add = 25
				OR = {
					has_trait = lunatic
					has_trait = vengeful
					has_trait = arrogant
				}
			}
			ai_value_modifier = {
				ai_energy = 0.25
				ai_rationality = -0.5
			}
		}
	}

	option = { #Pet
		name = {
			trigger = { exists = scope:pet_option_cat }
			text = fund_inspiration.0031.pet_option_cat
		}
		name = {
			trigger = { exists = scope:pet_option_dog }
			text = fund_inspiration.0031.pet_option_dog
		}
		trigger = {
			exists = scope:pet_option
		}
		scope:inspiration_owner = {
			set_variable = {
				name = book_subject
				value = flag:animals
			}
			if = {
				limit = {
					exists = scope:pet_option_cat
				}
				set_variable = {
					name = book_topic
					value = flag:animals_your_cat
				}
				set_variable = {
					name = book_topic_cat_name
					value = root.var:story_cycle_cat_name
				}
			}
			else = {
				set_variable = {
					name = book_topic
					value = flag:animals_your_dog
				}
				set_variable = {
					name = book_topic_dog_name
					value = root.var:story_cycle_dog_name
				}
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		ai_chance = {
			base = 0 #Not something the AI will do unless they're a kid
			modifier = {
				add = 100
				is_adult = no
			}
		}
	}

	option = { # Unification
		name = fund_inspiration.0031.c
		trigger = {
			exists = scope:book_topic_unification
		}
		scope:inspiration_owner = {
			if = {
				limit = {
					scope:united_title.tier >= tier_empire
				}
				set_variable = {
					name = book_subject
					value = flag:empire
				}
			}
			else = {
				set_variable = {
					name = book_subject
					value = flag:kingdom
				}
			}
			set_variable = {
				name = book_topic
				value = flag:unification
			}
			set_variable = {
				name = book_topic_united_title
				value = scope:united_title
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 0.75
			}
			modifier = {
				add = 25
				has_trait = arrogant
			}
			modifier = {
				add = 25
				scope:united_title.tier >= tier_empire
			}
		}
	}

	option = { # Formed/created/founded
		name = fund_inspiration.0031.d
		trigger = {
			exists = scope:book_topic_creation
		}
		scope:inspiration_owner = {
			if = {
				limit = {
					scope:created_title.tier >= tier_empire
				}
				set_variable = {
					name = book_subject
					value = flag:empire
				}
			}
			else = {
				set_variable = {
					name = book_subject
					value = flag:kingdom
				}
			}
			set_variable = {
				name = book_topic
				value = flag:creation
			}
			set_variable = {
				name = book_topic_created_title
				value = scope:created_title
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 0.75
			}
			modifier = {
				add = 25
				has_trait = arrogant
			}
			modifier = {
				add = 25
				scope:created_title.tier >= tier_empire
			}
		}
	}

	option = { # Restored
		name = fund_inspiration.0031.e
		trigger = {
			exists = scope:book_topic_restoration
		}
		scope:inspiration_owner = {
			if = {
				limit = {
					scope:restored_title.tier >= tier_empire
				}
				set_variable = {
					name = book_subject
					value = flag:empire
				}
			}
			else = {
				set_variable = {
					name = book_subject
					value = flag:kingdom
				}
			}
			set_variable = {
				name = book_topic
				value = flag:restoration
			}
			set_variable = {
				name = book_topic_restored_title
				value = scope:restored_title
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 0.75
			}
			modifier = {
				add = 25
				has_trait = arrogant
			}
			modifier = {
				add = 25
				scope:restored_title.tier >= tier_empire
			}
		}
	}

	option = { #I don't care!
		name = fund_inspiration.0031.f
		scope:subject = {
			scope:inspiration_owner = {
				set_variable = {
					name = book_subject
					value = prev
				}
			}
		}
		custom_tooltip = fund_inspiration.they_decide_option_tt
		ai_chance = {
			base = 0
		}
	}
}


# Book - they have a subject
# by Linnéa Thimrén
fund_inspiration.0032 = {
	hidden = yes

	trigger = {
		scope:inspiration = {
			has_inspiration_type = book_inspiration
			inspiration_owner = { #They have already decided what to write about 
				exists = var:book_subject
			}
		}
	}

	immediate = {
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		send_interface_toast = {
			title = fund_inspiration.0032.t
			left_icon = scope:inspiration_owner
			show_as_tooltip = {
				fund_inspiration_effect = yes
			}
		}
		hidden_effect = {
			if = { # If they're a witch and you're funding their questionable projects they might try to recruit you
				limit = {
					OR = {
						scope:inspiration_owner.var:book_subject = flag:medicine
						scope:inspiration_owner.var:book_subject = flag:witch
					}
					scope:inspiration_owner = {
						is_witch_trigger = yes
						can_start_scheme = {
							type = convert_to_witchcraft
							target_character = root
						}
					}
					is_witch_trigger = no
				}
				random = {
					chance = 50
					modifier = {
						add = 25
						trigger = {
							scope:inspiration_owner.var:book_subject = flag:witch
						}
					}
					scope:inspiration_owner = {
						start_scheme = {
							type = convert_to_witchcraft
							target_character = root
						}
					}
				}
			}
		}
	}
}


# Tapestry - Choose a Subject
# by Sean Hughes
fund_inspiration.0041 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.0041.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	trigger = {
		scope:inspiration = {
			has_inspiration_type = weaver_inspiration
		}
		scope:inspiration_owner = {
			NOR = {
				exists = var:artifact_tapestry_scene
				has_variable = banner_commission
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"

		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}

		random_list = {
			pick = 3
			unique = yes

			999 = { # A tribute to my victory at [location].
				trigger = {
					exists = var:epic_battle_location
					exists = var:epic_loser
				}
				save_scope_value_as = {
					name = option_battle
					value = yes
				}
			}
			10 = { # Something Abstract
				trigger = {
					faith_is_aniconic_trigger = yes
				}
				ai_value_modifier = {
					ai_zeal = 0.2
				}
				modifier = {
					add = {
						value = learning
						subtract = decent_skill_rating
					}
				}
				save_scope_value_as = {
					name = option_abstract
					value = yes
				}
			}
			10 = { # Something showcasing the untamed beauty of nature
				save_scope_value_as = {
					name = option_nature
					value = yes
				}
				modifier = {
					add = {
						value = prowess
						subtract = decent_skill_rating
					}
				}
			}
			10 = { # Something that illustrates the history of the realm
				trigger = {
					faith_is_aniconic_trigger = no
				}
				save_scope_value_as = {
					name = option_history
					value = yes
				}
				modifier = {
					add = {
						value = diplomacy
						subtract = decent_skill_rating
					}
				}
			}
			10 = { # Something representing life in the realm
				trigger = {
					faith_is_aniconic_trigger = no
				}
				save_scope_value_as = {
					name = option_life
					value = yes
				}
				modifier = {
					add = {
						value = stewardship
						subtract = decent_skill_rating
					}
				}
			}
		}
	}

	option = {  # A tribute to my victory at [location].
		trigger = {
			exists = scope:option_battle
			exists = var:epic_battle_location
			exists = var:epic_loser
		}
		name = fund_inspiration.0041.option_battle

		hidden_effect = {
			scope:inspiration_owner = {
				set_variable = {
					name = artifact_tapestry_scene
					value = flag:battle
				}
			}
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 2
				ai_honor = 1
			}
			modifier = {
				add = 100
				has_trait = brave
			}
			modifier = {
				add = 50
				has_trait = education_martial
			}
			modifier = {
				factor = 0
				has_trait = craven
			}
		}
	}

	option = { # Something Abstract
		trigger = {
			exists = scope:option_abstract
			faith_is_aniconic_trigger = yes
		}
		name = fund_inspiration.0041.option_abstract

		hidden_effect = {
			random_list = {
				40 = {
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:geometric_patterns
						}
					}
				}
				60 = {
					trigger = {	scope:inspiration_owner = {	religion = religion:islam_religion } }
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:calligraphic
						}
					}
				}
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 2
			}
			modifier = {
				add = {
					value = learning
					subtract = decent_skill_rating
					multiply = 10
				}
			}
		}
	}
	
	option = { # Something showcasing the untamed beauty of nature
		trigger = {
			exists = scope:option_nature
		}
		name = fund_inspiration.0041.option_nature
		hidden_effect = {
			random_list = {
				33 = {
					trigger = {	NOT = { faith = { has_doctrine_parameter = pacifist_opinion_active } } }
					modifier = {
						has_trait = lifestyle_hunter
						factor = 4 # 66% chance if hunter, 33% chance otherwise
					}
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:hunt
						}
					}
				}
				33 = {
					trigger = {	NOT = { faith = { has_doctrine_parameter = pacifist_opinion_active } } }
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:animals
						}
					}
				}
				33 = {
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:garden
						}
					}
				}
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 400
				has_trait = witch
			}
		}
	}

	option = { # Something that illustrates the history of the realm
		trigger = {
			exists = scope:option_history
			faith_is_aniconic_trigger = no
		}
		name = fund_inspiration.0041.option_history
		hidden_effect = {
			random_list = {
				50 = {
					trigger = {
						culture = {						
							OR = {
								has_cultural_tradition = tradition_seafaring
								has_cultural_tradition = tradition_maritime_mercantilism
							}
						}
					}
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:ships
						}
					}
				}
				25 = {
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:historical
						}
					}
				}
				25 = {
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:coronation
						}
					}
				}
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				add = 200
				has_trait = arrogant
			}
			modifier = {
				add = {
					value = diplomacy
					subtract = decent_skill_rating
					multiply = 10
				}
			}
		}
	}

	option = { # Something representing life in the realm
		trigger = {
			exists = scope:option_life
			faith_is_aniconic_trigger = no
		}
		name = fund_inspiration.0041.option_life
		hidden_effect = {
			random_list = {
				33 = {
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:bucolic
						}
					}
				}
				33 = {
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:banquet
						}
					}
				}
				33 = {
					scope:inspiration_owner = {
						set_variable = {
							name = artifact_tapestry_scene
							value = flag:hearing
						}
					}
				}
			}
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_sociability = 1
			}
			modifier = {		
				add = {
					value = stewardship
					subtract = decent_skill_rating
					multiply = 10
				}
			}
		}
	}

	after = {
		custom_tooltip = fund_inspiration.you_decide_option_tt
	}
}

# Tapestry - Subject already chosen
# by Sean Hughes
fund_inspiration.0042 = {
	hidden = yes

	trigger = {
		scope:inspiration = {
			has_inspiration_type = weaver_inspiration
			inspiration_owner = { #They know what tapestry they want to make 
				exists = var:artifact_tapestry_scene
			}
		}
	}

	immediate = {
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		send_interface_toast = {
			title = fund_inspiration.0042.t
			left_icon = scope:inspiration_owner
			show_as_tooltip = {
				fund_inspiration_effect = yes
			}
		}
	}
}

# Banner - Choose a Subject
# by Joe Parkin
fund_inspiration.0043 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.0043.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	trigger = {
		scope:inspiration = {
			has_inspiration_type = weaver_inspiration
			inspiration_owner = { has_variable = banner_commission }
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"

		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
	}

	option = { # Title
		name = fund_inspiration.0043.option_title
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_banner_type
				value = flag:title
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_honor = 1
				ai_boldness = -0.5
			}
		}
	}

	option = { # House
		name = fund_inspiration.0043.option_house
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_banner_type
				value = flag:house
			}
		}
		ai_chance = {
			base = 25
			modifier = {
				factor = 2
				house.house_head = root
			}
			modifier = {
				factor = 0.5
				any_character_artifact = {
					exists = var:banner_house
					var:banner_house = root.house
				}
			}
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}
	
	option = { # Dynasty
		name = fund_inspiration.0043.option_dynasty
		trigger = {
			AND = {
				OR = {
					this = dynasty.dynast # Dynasty Head
					any_parent = { # Parent landless
						employer = prev
						dynasty = prev.dynasty
						this = dynasty.dynast
					}
				}
				NOR = {
					any_artifact = {
						trigger_if = {
							limit = { exists = var:banner_dynasty }
							var:banner_dynasty = root.dynasty
						}
						trigger_else = { always = no }
						OR = {
							artifact_owner = root
							artifact_owner = { in_diplomatic_range = root }
						}
					}
					any_inspiration = {
						inspiration_sponsor.dynasty = root.dynasty
						inspiration_owner = {
							has_variable = banner_commission
							trigger_if = {
								limit = { exists = var:artifact_banner_type }
								var:artifact_banner_type = flag:dynasty
							}
							trigger_else = { always = no }
						}
					}
				}
			}
		}
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_banner_type
				value = flag:dynasty
			}
		}
		custom_tooltip = fund_inspiration.0043.option_dynasty_tt
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}

	after = {
		custom_tooltip = fund_inspiration.you_decide_option_tt
	}
}

# Wall Hanging - choose tapestry or banner
fund_inspiration.0044 = {
	type = character_event
	title = fund_inspiration.0044.t
	desc = fund_inspiration.0044.desc
	theme = realm
	override_background = {
		reference = study
	}
	left_portrait = {
		character = scope:antiquarian
		animation = steward
	}

	option = { # Tapestry
		name = fund_inspiration.0044.option_tapestry
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_honor = 1
			}
		}
	}

	option = { # Banner
		name = fund_inspiration.0044.option_banner
		scope:local_artisan = { set_variable = banner_commission }
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}

	after = {
		scope:local_artisan = {
			create_inspiration = weaver_inspiration
			inspiration = {
				save_scope_as = this_inspiration
			}
			if = {
				# To avoid false-positives during tooltip generation.
				limit = { exists = scope:this_inspiration }
				root = { sponsor_inspiration = scope:this_inspiration }
			}
		}
		custom_tooltip = fund_inspiration.you_decide_tapestry_option_tt
	}
}

# Adventurer - Choose destination
# By Bianca Savazzi and Linnéa Thimrén

# What options should we show?
scripted_effect fund_inspiration_0051_pick_options_to_show_effect = {
	hidden_effect = {
		random_list = {
			1 = {
				# Kinai
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_kinai
						}
					}
					NOT = { exists = scope:kinai_option }
				}
				save_scope_value_as = {
					name = kinai_option
					value = yes
				}
			}
			1 = {
				# Tokaido
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_tokaido
						}
					}
					NOT = { exists = scope:tokaido_option }
				}
				save_scope_value_as = {
					name = tokaido_option
					value = yes
				}
			}
			1 = {
				# Tosando
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_tosando
						}
					}
					NOT = { exists = scope:tosando_option }
				}
				save_scope_value_as = {
					name = tosando_option
					value = yes
				}
			}
			1 = {
				# Hokurikudo
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_hokurikudo
						}
					}
					NOT = { exists = scope:hokurikudo_option }
				}
				save_scope_value_as = {
					name = hokurikudo_option
					value = yes
				}
			}
			1 = {
				# Sanindo
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_san'indo
						}
					}
					NOT = { exists = scope:sanindo_option }
				}
				save_scope_value_as = {
					name = sanindo_option
					value = yes
				}
			}
			1 = {
				# Sanyodo
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_san'yodo
						}
					}
					NOT = { exists = scope:sanyodo_option }
				}
				save_scope_value_as = {
					name = sanyodo_option
					value = yes
				}
			}
			1 = {
				# Nankaido
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_nankaido
						}
					}
					NOT = { exists = scope:nankaido_option }
				}
				save_scope_value_as = {
					name = nankaido_option
					value = yes
				}
			}
			1 = {
				# Saikaido
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_saikaido
						}
					}
					NOT = { exists = scope:saikaido_option }
				}
				save_scope_value_as = {
					name = saikaidooption
					value = yes
				}
			}
			1 = {
				# Hokkaido
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_hokkaido
						}
					}
					NOT = { exists = scope:hokkaido_option }
				}
				save_scope_value_as = {
					name = hokkaido_option
					value = yes
				}
			}
			1 = {
				# Karafuto
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_karafuto
						}
					}
					NOT = { exists = scope:karafuto_option }
				}
				save_scope_value_as = {
					name = karafuto_option
					value = yes
				}
			}
			1 = {
				# Ryukyu
				trigger = {
					scope:inspiration_owner = {
						adventurer_potential_destination_distance_check = {
							REGION = world_circuit_ryukyu
						}
					}
					NOT = { exists = scope:ryukyu_option }
				}
				save_scope_value_as = {
					name = ryukyu_option
					value = yes
				}
			}
		}
	}
}

scripted_effect fund_adventure_inspiration_start_effect = {
	hidden_effect = {
		if = { #Should always exists, but we add this check to avoid the tooltip errors
			limit = {
				exists = $ADVENTURER$.var:adventure_destination
			}
			get_adventure_inspiration_start_location = { ADVENTURER = $ADVENTURER$ } #To save the location so we can use it in the effect
		}
		if = { #Should always exists, but we add this check to avoid the tooltip errors
			limit = {
				exists = scope:location
				exists = scope:location.title_province
			}
			start_adventure_effect = {
				ADVENTURER = $ADVENTURER$
				LOCATION = scope:location.title_province
			}
		}
	}
}

fund_inspiration.0051 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.0051.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
			inspiration_owner = { #They haven't already decided where to go 
				NOT = { exists = var:adventure_destination }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		#Saving some scopes for the tooltips

		save_scope_as = actor
		scope:inspiration_owner = {
			assign_quirk_effect = yes
			save_scope_as = recipient
		}
		show_as_tooltip = {
			fund_inspiration_effect = yes
		}
		fund_inspiration_0051_pick_options_to_show_effect = yes
		fund_inspiration_0051_pick_options_to_show_effect = yes
		fund_inspiration_0051_pick_options_to_show_effect = yes
	}

	option = {
		name = world_circuit_kinai
		trigger = { exists = scope:kinai_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:kinai
			}
		}

		ai_chance = {
			base = 50
		}
	}

	option = {
		name = world_circuit_tokaido
		trigger = { exists = scope:tokaido_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:tokaido
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = world_circuit_tosando
		trigger = { exists = scope:tosando_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:tosando
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = world_circuit_hokurikudo
		trigger = { exists = scope:hokurikudo_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:hokurikudo
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = world_circuit_sanindo
		trigger = { exists = scope:sanindo_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:sanindo
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = world_circuit_sanyodo
		trigger = { exists = scope:sanyodo_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:sanyodo
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = world_circuit_nankaido
		trigger = { exists = scope:nankaido_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:nankaido
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = world_circuit_saikaido
		trigger = { exists = scope:saikaido_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:saikaido
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = world_circuit_hokkaido
		trigger = { exists = scope:hokkaido_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:hokkaido
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = world_circuit_karafuto
		trigger = { exists = scope:karafuto_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:karafuto
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = {
		name = world_circuit_ryukyu
		trigger = { exists = scope:ryukyu_option }
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_destination
				value = flag:ryukyu
			}
		}
		ai_chance = {
			base = 50
		}
	}

	option = { #Go where you want to go!
		name = fund_inspiration.0051.d
		custom_tooltip = fund_inspiration.they_decide_option_tt
		set_adventure_location_effect = {
			BASE_SCOPE = scope:inspiration_owner
			NO_DESTINATION = no
		}

		ai_chance = {
			base = 5
			modifier = {
				add = 25
				OR = {
					has_trait = arbitrary
					has_trait = lazy
				}
			}
		}
	}
}

# Adventure - Destination already chosen
# by Linnéa Thimrén
fund_inspiration.0052 = {
	hidden = yes

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
			inspiration_owner = { #They have already decided where to go 
				exists = var:adventure_destination
			}
		}
	}

	immediate = {
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
			set_variable = gone_adventuring
		}
		send_interface_toast = {
			title = fund_inspiration.0052.t
			left_icon = scope:inspiration_owner
			show_as_tooltip = {
				fund_inspiration_effect = yes
			}
		}
	}
}


# Adventure maintenance, to make sure the inspiration progresses and to trigger the completion event 

scripted_effect fund_adventure_inspiration_travel_progress_effect = {
	if = { # Kinai
		limit = {
			var:adventure_destination = flag:kinai
		}
		random_county_in_region = {
			region = world_circuit_kinai
			title_province = { save_scope_as = location }
		}
	}
	else_if = { # Tokaido
		limit = {
			var:adventure_destination = flag:tokaido
		}
		random_county_in_region = {
			region = world_circuit_tokaido
			title_province = { save_scope_as = location }
		}
	}
	else_if = { # Tosando
		limit = {
			var:adventure_destination = flag:tosando
		}
		random_county_in_region = {
			region = world_circuit_tosando
			title_province = { save_scope_as = location }
		}
	}
	else_if = { # Hokurikudo
		limit = {
			var:adventure_destination = flag:hokurikudo
		}
		random_county_in_region = {
			region = world_circuit_hokurikudo
			title_province = { save_scope_as = location }
		}
	}
	else_if = { # Sanindo
		limit = {
			var:adventure_destination = flag:sanindo
		}
		random_county_in_region = {
			region = world_circuit_san'indo
			title_province = { save_scope_as = location }
		}
	}
	else_if = { # Sanyodo
		limit = {
			var:adventure_destination = flag:sanyodo
		}
		random_county_in_region = {
			region = world_circuit_san'yodo
			title_province = { save_scope_as = location }
		}
	}
	else_if = { # Nankaido
		limit = {
			var:adventure_destination = flag:nankaido
		}
		random_county_in_region = {
			region = world_circuit_nankaido
			title_province = { save_scope_as = location }
		}
	}
	else_if = { # Saikaido
		limit = {
			var:adventure_destination = flag:saikaido
		}
		random_county_in_region = {
			region = world_circuit_saikaido
			title_province = { save_scope_as = location }
		}
	}
	else_if = { # Hokkaido
		limit = {
			var:adventure_destination = flag:hokkaido
		}
		random_county_in_region = {
			region = world_circuit_hokkaido
			title_province = { save_scope_as = location }
		}
	}
	else_if = { # Karafuto
		limit = {
			var:adventure_destination = flag:karafuto
		}
		random_county_in_region = {
			region = world_circuit_karafuto
			title_province = { save_scope_as = location }
		}
	}
	else_if = { # Ryukyu
		limit = {
			var:adventure_destination = flag:ryukyu
		}
		random_county_in_region = {
			region = world_circuit_ryukyu
			title_province = { save_scope_as = location }
		}
	}

	scope:inspiration_owner = {
		set_location = {
			location = scope:location
			stick_to_location = yes
		}
	}
}


# Triggered from on_progress_increased in the adventurer inspiration script - to mimic progress happening over the years
# by Linnéa Thimrén
fund_inspiration.0053 = {
	hidden = yes

	trigger = {
		exists = inspiration
		inspiration = {
			has_inspiration_type = adventure_inspiration
			exists = inspiration_sponsor
			inspiration_sponsor = { is_alive = yes }
			inspiration_progress < 10
		}
	}

	immediate = {
		fund_adventure_inspiration_travel_progress_effect = yes #Adventurer moves on to a new location in the targeted region.
	}
}

# Adventure - Fallback to end it all if it's been going on for too long. Triggered from start_adventure_effect
# by Linnéa Thimrén
fund_inspiration.0054 = {
	hidden = yes

	trigger = {
		exists = inspiration
		inspiration = {
			has_inspiration_type = adventure_inspiration
			exists = inspiration_sponsor
			inspiration_sponsor = { is_alive = yes }
		}
	}

	on_trigger_fail = { #If something has gone wrong we do some cleanup
		if = {
			limit = { exists = scope:inspiration }
			save_scope_as = inspiration_owner
			inspiration_completion_effect = yes
			if = {
				limit = { exists = scope:inspiration.inspiration_sponsor }
				scope:inspiration.inspiration_sponsor = { end_inspiration_sponsorship = scope:inspiration }
			}
		}
	}

	immediate = {
		# Send adventurer back home 
		scope:inspiration_owner = {
			set_location_to_default = yes
		}
		#Finish the inspiration
		inspiration = { change_inspiration_progress = 10 }
	}
}



# Artisan - Choose what they make
scripted_trigger fund_inspiration_0061_option_chest_trigger = {
	NOT = { exists = scope:artisan_type_chest_option }
}
scripted_trigger fund_inspiration_0061_option_box_trigger = {
	NOT = { exists = scope:artisan_type_box_option }
}
scripted_trigger fund_inspiration_0061_option_sculpture_trigger = {
	NOT = { exists = scope:artisan_type_sculpture_option }
}
scripted_trigger fund_inspiration_0061_option_cabinet_trigger = {
	NOT = { exists = scope:artisan_type_cabinet_option }
}
scripted_trigger fund_inspiration_0061_option_throne_trigger = {
	NOT = { exists = scope:artisan_type_throne_option }
}
scripted_trigger fund_inspiration_0061_option_scientific_apparatus_trigger = {
	# Currently the only available apparatus is DLC-locked - mildly rework this trigger if we add more.
	has_fp2_dlc_trigger = yes
	# We need to verify that the character is eligible
	eligible_for_scientific_apparatus_armillary_sphere_trigger = { CHARACTER = root }
	NOT = { exists = scope:artisan_type_scientific_apparatus_option }
}
scripted_trigger fund_inspiration_0061_option_urn_trigger = {
	NOT = { exists = scope:artisan_type_urn_option }
}
scripted_trigger fund_inspiration_0061_option_icon_trigger = {
	NOT = { exists = scope:artisan_type_icon_option }
	faith_is_aniconic_trigger = no
}
scripted_effect fund_inspiration_0061_pick_options_to_show_effect = {
	#What options do we show?
	hidden_effect = {
		random_list = {
			10 = {
				trigger = {
					fund_inspiration_0061_option_chest_trigger = yes
				}
				save_scope_value_as = {
					name = artisan_type_chest_option
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0061_option_box_trigger = yes
				}
				save_scope_value_as = {
					name = artisan_type_box_option
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0061_option_sculpture_trigger = yes
				}
				save_scope_value_as = {
					name = artisan_type_sculpture_option
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0061_option_cabinet_trigger = yes
				}
				save_scope_value_as = {
					name = artisan_type_cabinet_option
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0061_option_throne_trigger = yes
				}
				save_scope_value_as = {
					name = artisan_type_throne_option
					value = yes
				}
			}
			# DLC options get a boost to make them more visible.
			50 = {
				trigger = {
					fund_inspiration_0061_option_scientific_apparatus_trigger = yes
				}
				save_scope_value_as = {
					name = artisan_type_scientific_apparatus_option
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0061_option_urn_trigger = yes
				}
				save_scope_value_as = {
					name = artisan_type_urn_option
					value = yes
				}
			}
			50 = {
				trigger = {
					fund_inspiration_0061_option_icon_trigger = yes
				}
				save_scope_value_as = {
					name = artisan_type_icon_option
					value = yes
				}
			}
		}
	}
}

fund_inspiration.0061 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.0061.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	trigger = {
		scope:inspiration = {
			has_inspiration_type = artisan_inspiration
			inspiration_owner = { #They haven't already decided what to make 
				NOT = { exists = var:artifact_artisan_type }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		
		show_as_tooltip = {
			fund_inspiration_effect = yes
		}

		# What options should we show?
		fund_inspiration_0061_pick_options_to_show_effect = yes
		fund_inspiration_0061_pick_options_to_show_effect = yes
		fund_inspiration_0061_pick_options_to_show_effect = yes
	}

	#Chest
	option = {
		name = fund_inspiration.0061.chest
		trigger = {
			exists = scope:artisan_type_chest_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_artisan_type
				value = flag:artisan_type_chest
			}
		}
		ai_chance = {
			base = 10
			
		}
	}

	#Box
	option = {
		name = fund_inspiration.0061.box
		trigger = {
			exists = scope:artisan_type_box_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_artisan_type
				value = flag:artisan_type_box
			}
		}
		ai_chance = {
			base = 10
			
		}
	}

	#Sculpture
	option = {
		name = fund_inspiration.0061.sculpture
		trigger = {
			exists = scope:artisan_type_sculpture_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_artisan_type
				value = flag:artisan_type_sculpture
			}
		}
		ai_chance = {
			base = 10
		}
	}

	#Cabinet
	option = {
		name = fund_inspiration.0061.cabinet
		trigger = {
			exists = scope:artisan_type_cabinet_option
			scope:inspiration_owner = {
				NOR = {
					artifact_use_indian_building_visuals_trigger = yes
					artifact_use_mena_building_visuals_trigger = yes
				}
			}
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_artisan_type
				value = flag:artisan_type_cabinet
			}
		}
		ai_chance = {
			base = 10
			
		}
	}

	#Diwan
	option = {
		name = fund_inspiration.0061.diwan
		trigger = {
			exists = scope:artisan_type_cabinet_option
			scope:inspiration_owner = { artifact_use_indian_building_visuals_trigger = yes }
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_artisan_type
				value = flag:artisan_type_cabinet
			}
		}
		ai_chance = {
			base = 10
			
		}
	}

	#Table
	option = {
		name = fund_inspiration.0061.table
		trigger = {
			exists = scope:artisan_type_cabinet_option
			scope:inspiration_owner = { artifact_use_mena_building_visuals_trigger = yes }
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_artisan_type
				value = flag:artisan_type_cabinet
			}
		}
		ai_chance = {
			base = 10
			
		}
	}

	#Throne
	option = {
		name = fund_inspiration.0061.throne
		trigger = {
			exists = scope:artisan_type_throne_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_artisan_type
				value = flag:artisan_type_throne
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				factor = 0
				OR = {
					any_character_artifact = { # Has a fantastic item already
						artifact_slot_type = throne
						rarity = illustrious
					}
					AND = { # Have a lot of artifacts already, and the inspired person isn't even very good
						scope:inspiration_owner = {
							artisan_inspiration_average_skill_value < high_inspiration_skill
						}
						any_character_artifact = {
							count >= 2
							artifact_slot_type = throne
						}
					}
				}
			}
		}
	}

	#Scientific Apparatus
	option = {
		name = fund_inspiration.0061.scientific_apparatus
		trigger = {
			exists = scope:artisan_type_scientific_apparatus_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			roll_scientific_apparatus_effect = { CHARACTER = root }
			set_variable = {
				name = artifact_artisan_type
				value = flag:artisan_type_scientific_apparatus
			}
		}
		ai_chance = {
			base = 10
		}
	}

	#Urn
	option = {
		name = fund_inspiration.0061.urn
		trigger = {
			exists = scope:artisan_type_urn_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_artisan_type
				value = flag:artisan_type_urn
			}
		}
		ai_chance = {
			base = 10
		}
	}

	#Icon
	option = {
		name = fund_inspiration.0061.icon
		trigger = {
			exists = scope:artisan_type_icon_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_artisan_type
				value = flag:artisan_type_icon
			}
		}
		ai_chance = {
			base = 10
		}
	}
}

# Artisan - they know what they want to make
# by Linnéa Thimrén
fund_inspiration.0062 = {
	hidden = yes

	trigger = {
		scope:inspiration = {
			has_inspiration_type = artisan_inspiration
			inspiration_owner = { #They have already decided what to make 
				exists = var:artifact_artisan_type
			}
		}
	}

	immediate = {
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		send_interface_toast = {
			title = fund_inspiration.0062.t
			left_icon = scope:inspiration_owner
			show_as_tooltip = {
				fund_inspiration_effect = yes
			}
		}
	}
}


# Smith - Choose what they make
# by Linnéa Thimrén
scripted_trigger fund_inspiration_0071_option_brooch_trigger = {
	NOT = { exists = scope:smith_type_brooch_option }
}
scripted_trigger fund_inspiration_0071_option_regalia_trigger = {
	NOT = { exists = scope:smith_type_regalia_option }
}
scripted_trigger fund_inspiration_0071_option_crown_trigger = {
	NOT = { exists = scope:smith_type_crown_option }
}
scripted_trigger fund_inspiration_0071_option_goblet_trigger = {
	NOT = { exists = scope:smith_type_goblet_option }
}
scripted_trigger fund_inspiration_0071_option_aquamanile_trigger = {
	has_fp2_dlc_trigger = yes
	NOT = { exists = scope:smith_type_aquamanile_option }
	# These occurred in other faiths too, so we don't restrict their religious usage, but were much more ubiquitous in Islam.
	religion = religion:islam_religion
}
scripted_trigger fund_inspiration_0071_option_incense_burner_sculpture_trigger = {
	has_fp3_dlc_trigger = yes
	NOT = { exists = scope:smith_type_incense_burner_sculpture_option }
	# These occurred in other faiths too, so we don't restrict their religious usage, but were much more ubiquitous in Islam.
	religion = religion:islam_religion
}
scripted_effect fund_inspiration_0071_pick_options_to_show_effect = {
	#What options do we show?
	hidden_effect = {
		random_list = {
			10 = {
				trigger = {
					fund_inspiration_0071_option_brooch_trigger = yes
				}
				save_scope_value_as = {
					name = smith_type_brooch_option
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0071_option_regalia_trigger = yes
				}
				save_scope_value_as = {
					name = smith_type_regalia_option
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0071_option_crown_trigger = yes
				}
				save_scope_value_as = {
					name = smith_type_crown_option
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0071_option_goblet_trigger = yes
				}
				save_scope_value_as = {
					name = smith_type_goblet_option
					value = yes
				}
			}
			# DLC options get a boost to make them more visible.
			50 = {
				trigger = {
					fund_inspiration_0071_option_aquamanile_trigger = yes
				}
				save_scope_value_as = {
					name = smith_type_aquamanile_option
					value = yes
				}
			}
			50 = {
				trigger = {
					fund_inspiration_0071_option_incense_burner_sculpture_trigger = yes
				}
				save_scope_value_as = {
					name = smith_type_incense_burner_sculpture_option
					value = yes
				}
			}
		}
	}
}

fund_inspiration.0071 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.0071.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	trigger = {
		scope:inspiration = {
			has_inspiration_type = smith_inspiration
			inspiration_owner = { #They haven't already decided what to make 
				NOT = { exists = var:artifact_smith_type }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		
		show_as_tooltip = {
			fund_inspiration_effect = yes
		}

		# What options should we show?
		fund_inspiration_0071_pick_options_to_show_effect = yes
		fund_inspiration_0071_pick_options_to_show_effect = yes
		fund_inspiration_0071_pick_options_to_show_effect = yes
	}

	#Brooch
	option = {
		name = fund_inspiration.0071.brooch
		trigger = {
			exists = scope:smith_type_brooch_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_smith_type
				value = flag:smith_type_brooch
			}
		}
		ai_chance = {
			base = 10
			
			modifier = {
				factor = 0
				OR = {
					any_character_artifact = { # Has a fantastic item already
						artifact_slot_type = miscellaneous
						rarity = illustrious
					}
					AND = { # Have a lot of artifacts already, and the inspired person isn't even very good
						scope:inspiration_owner = {
							smith_inspiration_average_skill_value < high_inspiration_skill
						}
						any_character_artifact = {
							count >= 4
							artifact_slot_type = miscellaneous
						}
					}
				}
			}
		}
	}

	#Regalia
	option = {
		name = fund_inspiration.0071.regalia
		trigger = {
			exists = scope:smith_type_regalia_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_smith_type
				value = flag:smith_type_regalia
			}
		}
		ai_chance = {
			base = 10
			
			modifier = {
				factor = 0
				OR = {
					any_character_artifact = { # Has a fantastic item already
						artifact_slot_type = regalia
						rarity = illustrious
					}
					AND = { # Have a lot of artifacts already, and the inspired person isn't even very good
						scope:inspiration_owner = {
							smith_inspiration_average_skill_value < high_inspiration_skill
						}
						any_character_artifact = {
							count >= 2
							artifact_slot_type = regalia
						}
					}
				}
			}
		}
	}

	#Crown
	option = {
		name = fund_inspiration.0071.crown
		trigger = {
			exists = scope:smith_type_crown_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_smith_type
				value = flag:smith_type_crown
			}
		}
		ai_chance = {
			base = 10
			
			modifier = {
				factor = 0
				OR = {
					any_character_artifact = { # Has a fantastic item already
						artifact_slot_type = helmet
						rarity = illustrious
					}
					AND = { # Have a lot of artifacts already, and the inspired person isn't even very good
						scope:inspiration_owner = {
							smith_inspiration_average_skill_value < high_inspiration_skill
						}
						any_character_artifact = {
							count >= 2
							artifact_slot_type = helmet
						}
					}
				}
			}
		}
	}

	#Goblet
	option = {
		name = fund_inspiration.0071.goblet
		trigger = {
			exists = scope:smith_type_goblet_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_smith_type
				value = flag:smith_type_goblet
			}
		}
		ai_chance = {
			base = 10
			
		}
	}

	#Aquamanile
	option = {
		name = fund_inspiration.0071.aquamanile
		trigger = {
			exists = scope:smith_type_aquamanile_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_smith_type
				value = flag:smith_type_aquamanile
			}
		}
		ai_chance = {
			base = 10
			
		}
	}

	#Incense Burner Sculpture
	option = {
		name = fund_inspiration.0071.incense_burner_sculpture
		trigger = {
			exists = scope:smith_type_incense_burner_sculpture_option
		}
		custom_tooltip = fund_inspiration.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_smith_type
				value = flag:smith_type_incense_burner_sculpture
			}
		}
		ai_chance = {
			base = 10
			
		}
	}
}

# Smith - they know what they want to make
# by Linnéa Thimrén
fund_inspiration.0072 = {
	hidden = yes

	trigger = {
		scope:inspiration = {
			has_inspiration_type = smith_inspiration
			inspiration_owner = { #They have already decided what to make 
				exists = var:artifact_smith_type
			}
		}
	}

	immediate = {
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		send_interface_toast = {
			title = fund_inspiration.0072.t
			left_icon = scope:inspiration_owner
			show_as_tooltip = {
				fund_inspiration_effect = yes
			}
		}
	}
}


# Alchemy - Choose what they make
# by Linnéa Thimrén
scripted_trigger fund_inspiration_0081_option_elixirs_trigger = {
	NOT = { exists = scope:alchemy_type_elixirs }
}
scripted_trigger fund_inspiration_0081_option_metals_trigger = {
	NOT = { exists = scope:alchemy_type_metals }
}
scripted_trigger fund_inspiration_0081_option_panacea_trigger = {
	NOT = { exists = scope:alchemy_type_panacea }
}
scripted_trigger fund_inspiration_0081_option_immortality_trigger = {
	NOT = { exists = scope:alchemy_type_immortality }
}

scripted_effect fund_inspiration_0081_pick_options_to_show_effect = {
	#What options do we show?
	hidden_effect = {
		random_list = {
			10 = {
				trigger = {
					fund_inspiration_0081_option_elixirs_trigger = yes
				}
				save_scope_value_as = {
					name = alchemy_type_elixirs
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0081_option_metals_trigger = yes
				}
				save_scope_value_as = {
					name = alchemy_type_metals
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0081_option_panacea_trigger = yes
				}
				save_scope_value_as = {
					name = alchemy_type_panacea
					value = yes
				}
			}
			10 = {
				trigger = {
					fund_inspiration_0081_option_immortality_trigger = yes
				}
				save_scope_value_as = {
					name = alchemy_type_immortality
					value = yes
				}
			}
		}
	}
}

fund_inspiration.0081 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.0081.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	trigger = {
		scope:inspiration = {
			has_inspiration_type = alchemy_inspiration
			inspiration_owner = { #They haven't already decided what to make 
				NOT = { exists = var:artifact_alchemy_type }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
			assign_quirk_effect = yes
		}
		
		show_as_tooltip = {
			fund_inspiration_effect = yes
		}

		# What options should we show?
		fund_inspiration_0081_pick_options_to_show_effect = yes
		fund_inspiration_0081_pick_options_to_show_effect = yes
		fund_inspiration_0081_pick_options_to_show_effect = yes
	}

	#Elixir
	option = {
		name = fund_inspiration.0081.elixirs
		trigger = {
			exists = scope:alchemy_type_elixirs
		}
		custom_tooltip = fund_inspiration.0081.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_alchemy_type
				value = flag:alchemy_type_elixirs
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 10
				has_trait = scholar
			}
			ai_value_modifier = {
				ai_boldness = 0.15
				ai_rationality = 0.5
			}
		}
	}

	#Metals
	option = {
		name = fund_inspiration.0081.metals
		trigger = {
			exists = scope:alchemy_type_metals
		}
		custom_tooltip = fund_inspiration.0081.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_alchemy_type
				value = flag:alchemy_type_metals
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 15
				has_lifestyle = learning_lifestyle
			}
			ai_value_modifier = {
				ai_greed = 0.25
				ai_rationality = 0.15
				ai_boldness = 0.1
			}
		}
	}

	#Panacea
	option = {
		name = fund_inspiration.0081.panacea
		trigger = {
			exists = scope:alchemy_type_panacea
		}
		custom_tooltip = fund_inspiration.0081.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_alchemy_type
				value = flag:alchemy_type_panacea
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 25
				has_trait = lifestyle_physician
			}
			modifier = {
				add = 15
				has_lifestyle = learning_lifestyle
			}
			ai_value_modifier = {
				ai_zeal = 0.25
				ai_rationality = 0.25
				ai_boldness = -0.15
				ai_greed = -0.15
			}
		}
	}

	#Immortality
	option = {
		name = fund_inspiration.0081.immortality
		trigger = {
			exists = scope:alchemy_type_immortality
		}
		custom_tooltip = fund_inspiration.0081.you_decide_option_tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_alchemy_type
				value = flag:alchemy_type_immortality
			}
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 25
				has_trait = arrogant
			}
			ai_value_modifier = {
				ai_greed = 0.75
				ai_boldness = 0.5
				ai_zeal = -0.25
				ai_rationality = -0.15
			}
		}
	}

	#They decide
	option = {
		name = fund_inspiration.0031.f
		custom_tooltip = fund_inspiration.0081.they_decide_option_tt
		hidden_effect = {
			set_alchemy_inspiration_type_effect = {
				BASE_SCOPE = scope:inspiration_owner
				NO_TYPE = no
			}
		}
		ai_chance = {
			base = 0
		}
	}
}

# Alchemy - they know what they want to make
# by Linnéa Thimrén
fund_inspiration.0082 = {
	hidden = yes

	trigger = {
		scope:inspiration = {
			has_inspiration_type = alchemy_inspiration
			inspiration_owner = { #They have already decided what to make 
				exists = var:artifact_alchemy_type
			}
		}
	}

	immediate = {
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		send_interface_toast = {
			title = fund_inspiration.0082.t
			left_icon = scope:inspiration_owner
			show_as_tooltip = {
				fund_inspiration_effect = yes
			}
		}
	}
}

#Fund Inspiration: Bow - Choose your item
fund_inspiration.0091 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.0091.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	trigger = {
		scope:inspiration = {
			has_inspiration_type = bow_inspiration
		}
		scope:inspiration_owner = { NOT = { exists = var:artifact_bow_type } }
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		#Saving some scopes for the tooltips

		save_scope_as = actor
		scope:inspiration_owner = {
			assign_quirk_effect = yes
			save_scope_as = recipient
		}

	}

	# bow
	option = {
		name = fund_inspiration.0091.a
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_bow_type
				value = flag:artifact_bow_type_bow
			}
			custom_tooltip = fund_inspiration.0091.tooltip_bow.tt
		}
		ai_chance = {
			base = 50
		}
	}

	# longbow
	option = {
		name = fund_inspiration.0091.b
		trigger = {
			OR = {
				scope:inspiration_owner.culture = { has_cultural_tradition = tradition_longbow_competitions }
				culture = { has_cultural_tradition = tradition_longbow_competitions }
			}
		}
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_bow_type
				value = flag:artifact_bow_type_longbow
			}
			custom_tooltip = fund_inspiration.0091.tooltip_longbow.tt
		}
		ai_chance = {
			base = 50
		}
	}

	# composite bow
	option = {
		trigger = {
			OR = {
				scope:inspiration_owner.culture = { is_composite_bow_culture_trigger = yes }
				culture = { is_composite_bow_culture_trigger = yes }
			}
		}
		name = fund_inspiration.0091.c
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_bow_type
				value = flag:artifact_bow_type_composite
			}
			custom_tooltip = fund_inspiration.0091.tooltip_composite.tt
		}
		ai_chance = {
			base = 50
		}
	}

	# crossbow
	option = {
		name = fund_inspiration.0091.d
		trigger = {
			OR = {
				scope:inspiration_owner.culture = { has_innovation = innovation_advanced_bowmaking }
				culture = { has_innovation = innovation_advanced_bowmaking }
			}
		}
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_bow_type
				value = flag:artifact_bow_type_crossbow
			}
			custom_tooltip = fund_inspiration.0091.tooltip_crossbow.tt
		}
	}

	# default option of "do what you want"
	option = {
		name = fund_inspiration.0031.f
		hidden_effect = { #If they haven't specified what they're gonna make we decide it here
			set_bow_artifact_type_effect = {
				BASE_SCOPE = scope:inspiration_owner
				NO_TYPE = no
			}
		}
		custom_tooltip = fund_inspiration.they_decide_option_tt
		ai_chance = {
			base = 25
			modifier = {
				add = 25
				has_trait = arbitrary
			}
		}
	}
}

# Bow - they know what they want to make
fund_inspiration.0092 = {
	hidden = yes

	trigger = {
		scope:inspiration = {
			has_inspiration_type = bow_inspiration
			inspiration_owner = { #They know what weapon they want to make
				exists = var:artifact_weapon_type
			}
		}
	}

	immediate = {
		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}
		send_interface_toast = {
			title = fund_inspiration.0012.t
			left_icon = scope:inspiration_owner
			show_as_tooltip = {
				fund_inspiration_effect = yes
			}
		}
	}
}

##################################################
# Inspiration: complete!
# by Linnéa Thimrén
# 1001-2000
##################################################

# Fallback version - very generic
# by Linnéa Thimrén
fund_inspiration.1001 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = {
		desc = fund_inspiration.1001.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:tapestry
				}
				desc = artifact_wall_tapestry_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:small_hide
				}
				desc = artifact_small_hide_description
			}
			desc = artifact_crown_description 
		}
	}
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		if = {
			limit = {
				has_character_flag = trigger_tapestry_completion_event
			}
			remove_character_flag = trigger_tapestry_completion_event
			create_artifact_tapestry_effect = {
				OWNER = root
				WEAVER = scope:inspiration_owner
			}
			save_scope_value_as = {
				name = tapestry
				value = yes
			}
		}
		else_if = {
			limit = {
				has_character_flag = trigger_banner_completion_event
			}
			remove_character_flag = trigger_banner_completion_event
			if = {
				limit = {
					scope:inspiration_owner = { has_variable = artifact_banner_type }
				}
				switch = {
					trigger = scope:inspiration_owner.var:artifact_banner_type
					flag:dynasty = {
						root = { set_variable = banner_from_dynasty }
						create_artifact_wall_banner_effect = {
							OWNER = root
							CREATOR = scope:inspiration_owner
							TARGET = root.dynasty
						}
					}
					flag:house = {
						root = { set_variable = banner_from_house }
						create_artifact_wall_banner_effect = {
							OWNER = root
							CREATOR = scope:inspiration_owner
							TARGET = root.house
						}
					}
					flag:title = {
						create_artifact_wall_banner_effect = {
							OWNER = root
							CREATOR = scope:inspiration_owner
							TARGET = root.primary_title
						}
					}
				}
				scope:inspiration_owner = { remove_variable = artifact_banner_type }
			}
			save_scope_value_as = {
				name = banner
				value = yes
			}
		}
		else_if = {
			limit = {
				has_character_flag = trigger_adventure_completion_event
			}
			create_artifact_animal_hide_effect = {
				OWNER = root
				HUNTER = scope:inspiration_owner
				LEGENDARY = no
				ANIMAL = flag:none
			}
			save_scope_value_as = {
				name = small_hide
				value = yes
			}
		}
		else = {
			create_artifact_crown_effect = {
				OWNER = root
				SMITH = scope:inspiration_owner
			}
			save_scope_value_as = {
				name = crown
				value = yes
			}
		}
		#Inscribe your family motto
		if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_inscribe_motto_var
				}
				exists = scope:tapestry
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_motto_woven
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_e_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_e_var = {
					save_scope_as = dedication_e
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_e
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_f_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_f_var = {
					save_scope_as = dedication_f
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_f
			}
		}
	}

	#
	option = {
		name = fund_inspiration.1001.a
		if = {
			limit = {
				exists = scope:tapestry
			}
			custom_tooltip = create_artifact_tapestry_tooltip
		}
		else_if = {
			limit = {
				exists = scope:banner
			}
			custom_tooltip = create_artifact_banner_tooltip
		}
		else_if = {
			limit = {
				exists = scope:small_hide
			}
			custom_tooltip = create_artifact_small_hide_tooltip
		}
		else = {
			custom_tooltip = create_artifact_crown_tooltip #Fallback never shown
		}
	}

	after = {
		inspiration_completion_effect = yes
	}
}


# Weapon artifact
# by Linnéa Thimrén
fund_inspiration.1011 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = {
		desc = fund_inspiration.1011.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:weapon_type = flag:artifact_weapon_type_axe
				}
				desc = artifact_axe_description
			}
			triggered_desc = {
				trigger = {
					scope:weapon_type = flag:artifact_weapon_type_dagger
				}
				desc = artifact_dagger_description
			}
			triggered_desc = {
				trigger = {
					scope:weapon_type = flag:artifact_weapon_type_hammer
				}
				desc = artifact_hammer_description
			}
			triggered_desc = {
				trigger = {
					scope:weapon_type = flag:artifact_weapon_type_mace
				}
				desc = artifact_mace_description
			}
			triggered_desc = {
				trigger = {
					scope:weapon_type = flag:artifact_weapon_type_spear
				}
				desc = artifact_spear_description
			}
			triggered_desc = {
				trigger = {
					AND = { 
						scope:newly_created_artifact = {
							has_variable = replica_sassanian_sword
							OR = {
								rarity = famed
								rarity = illustrious
							}
						}
					}
				}
				desc = famed_replica_sassanian_sword_description
			}
			triggered_desc = {
				trigger = {
					AND = { 
						scope:newly_created_artifact = {
							has_variable = replica_sassanian_sword
							rarity = masterwork
						}
					}
				}
				desc = masterwork_replica_sassanian_sword_description
			}
			triggered_desc = {
				trigger = {
					AND = { 
						scope:newly_created_artifact = {
							has_variable = replica_sassanian_sword
							rarity = common
						}
					}
				}
				desc = common_replica_sassanian_sword_description
			}
			desc = artifact_sword_description
		}
	}
	theme = inspiration_complete
	override_background = { reference = armory }
	left_portrait = {
		character = scope:inspiration_owner
		triggered_animation = {
			trigger = { scope:weapon_type = flag:artifact_weapon_type_axe }
			animation = marshal_axe
		}
		triggered_animation = {
			trigger = { scope:weapon_type = flag:artifact_weapon_type_dagger }
			animation = marshal_dagger
		}
		triggered_animation = {
			trigger = { scope:weapon_type = flag:artifact_weapon_type_hammer }
			animation = celebrate_hammer
		}
		triggered_animation = {
			trigger = { scope:weapon_type = flag:artifact_weapon_type_mace }
			animation = marshal_mace
		}
		triggered_animation = {
			trigger = { scope:weapon_type = flag:artifact_weapon_type_spear }
			animation = throne_room_two_handed_passive_1
		}
		animation = marshal
	}
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_character_flag = trigger_weapon_completion_event
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		remove_character_flag = trigger_weapon_completion_event

		create_artifact_weapon_effect = {
			OWNER = root
			CREATOR = scope:inspiration_owner
			SET_WEAPON_TYPE = flag:no #Decided in the effect based on the variable saved on the inspiration owner
		}
		# Add a dedication to the description - fund_inspiration.7001
		if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_a_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_a_var = {
					save_scope_as = dedication_a
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_a
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_b_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_b_var = {
					save_scope_as = dedication_b
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_b
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_var = flag:dedication_c
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_c
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_d_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_d_var = {
					save_scope_as = dedication_d
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_d
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_e_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_e_var = {
					save_scope_as = dedication_e
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_e
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_f_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_f_var = {
					save_scope_as = dedication_f
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_f
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_g1_var
					has_variable = artifact_dedication_g2_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g1_var = {
					save_scope_as = dedication_g1
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g2_var = {
					save_scope_as = dedication_g2
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_g
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_h_var = flag:dedication_h
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_h
			}
		}
		#Inscribe your family motto
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_inscribe_motto_var
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_motto_inscribed
			}
		}
	}

	option = {
		name = fund_inspiration.1001.a
		custom_tooltip = create_artifact_weapon_tooltip
	}
}


# Armor artifact
# by Linnéa Thimrén
fund_inspiration.1021 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = {
		desc = {
			random_valid = {
				desc = fund_inspiration.1021.desc_opening_1
				desc = fund_inspiration.1021.desc_opening_2
			}
		}
		desc = fund_inspiration.1021.desc
		triggered_desc = {
			trigger = {
				NOT	= {
					scope:inspiration_owner.var:artifact_armor_type = flag:armor_type_shield
				}
			}
			desc = artifact_armor_description
		}
		triggered_desc = {
			trigger = {
				scope:inspiration_owner.var:artifact_armor_type = flag:armor_type_shield
			}
			desc = artifact_wall_shield_description
		}
	}
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_owner
		animation = marshal_shield
	}
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_character_flag = trigger_armor_completion_event
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		remove_character_flag = trigger_armor_completion_event
		
		if = {
			limit = {
				scope:inspiration_owner.var:artifact_armor_type = flag:armor_type_shield
			}
			if = {
				limit = {
					exists = house
				}
				house = {
					save_scope_as = coa_target
				}
			}
			else = {
				primary_title = {
					save_scope_as = coa_target
				}
			}
			create_artifact_wall_shield_effect = {
				OWNER = root
				TARGET = scope:coa_target
				CREATOR = scope:inspiration_owner
			}
		}
		else = {
			create_artifact_armor_effect = {
				OWNER = root
				CREATOR = scope:inspiration_owner
				SET_ARMOR_TYPE = flag:no #Decided in the effect based on the variable saved on the inspiration owner
			}
		}
		# Add a dedication to the description - fund_inspiration.7001
		if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_a_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_a_var = {
					save_scope_as = dedication_a
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_a
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_b_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_b_var = {
					save_scope_as = dedication_b
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_b
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_var = flag:dedication_c
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_c
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_d_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_d_var = {
					save_scope_as = dedication_d
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_d
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_e_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_e_var = {
					save_scope_as = dedication_e
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_e
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_f_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_f_var = {
					save_scope_as = dedication_f
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_f
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_g1_var
					has_variable = artifact_dedication_g2_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g1_var = {
					save_scope_as = dedication_g1
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g2_var = {
					save_scope_as = dedication_g2
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_g
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_h_var = flag:dedication_h
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_h
			}
		}
		#Inscribe your family motto
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_inscribe_motto_var
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_motto_inscribed
			}
		}
	}

	option = {
		name = fund_inspiration.1021.a
		custom_tooltip = create_artifact_armor_tooltip
	}
}

# Book artifact
# by Linnéa Thimrén
fund_inspiration.1031 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = {
		desc = {
			desc = fund_inspiration.1031.desc_opening
			first_valid = {
				triggered_desc = {
					trigger = {
						OR = {
							AND = {
								scope:newly_created_artifact = { has_artifact_feature = book_subject_witch }
								trait_is_criminal_in_faith_trigger = { TRAIT = witch FAITH = root.faith GENDER_CHARACTER = root }
							}
							AND = {
								scope:newly_created_artifact = { has_artifact_feature = book_subject_cannibal }
								trait_is_criminal_in_faith_trigger = { TRAIT = cannibal FAITH = root.faith GENDER_CHARACTER = root }
							}
							AND = {
								scope:newly_created_artifact = { has_artifact_feature = book_subject_deviant }
								trait_is_criminal_in_faith_trigger = { TRAIT = deviant FAITH = root.faith GENDER_CHARACTER = root }
							}
						}
					}
					desc = fund_inspiration.1031.desc_crime
				}
				triggered_desc = {
					trigger = { # Soulmate has passed away :(
						exists = scope:portrait_2_soulmate
						exists = scope:soulmate
						scope:soulmate = { is_alive = no }
					}
					desc = fund_inspiration.1031.desc_soulmate_died
				}
				triggered_desc = {
					trigger = { # Nemesis has passed away
						exists = scope:portrait_2_nemesis
						exists = scope:nemesis
						scope:nemesis = { is_alive = no }
					}
					desc = fund_inspiration.1031.desc_nemesis_died
				}
				triggered_desc = {
					trigger = { # Cat has passed away
						scope:newly_created_artifact = { has_artifact_feature = book_subject_animals }
						exists = scope:topic
						scope:topic = flag:animals_your_cat
						OR = {
							AND = { #No cat at all
								NOT = {
									any_owned_story = { story_type = story_cycle_pet_cat }
								}
							}
							AND = { #New cat
								any_owned_story = { story_type = story_cycle_pet_cat }
								exists = var:story_cycle_cat_name
								exists = scope:inspiration_owner.var:book_topic_cat_name
								NOT = {
									var:story_cycle_cat_name = scope:inspiration_owner.var:book_topic_cat_name
								}
							}
						}
					}
					desc = fund_inspiration.1031.desc_cat_died
				}
				triggered_desc = {
					trigger = { # Dog has passed away
						scope:newly_created_artifact = { has_artifact_feature = book_subject_animals }
						exists = scope:topic
						scope:topic = flag:animals_your_dog
						OR = {
							NOT = { #No dog at all
								any_owned_story = { story_type = story_cycle_pet_dog }
							}
							AND = { #New dog
								any_owned_story = { story_type = story_cycle_pet_dog }
								exists = var:story_cycle_dog_name
								exists = scope:inspiration_owner.var:book_topic_dog_name
								NOT = {
									var:story_cycle_dog_name = scope:inspiration_owner.var:book_topic_dog_name
								}
							}
						}
					}
					desc = fund_inspiration.1031.desc_dog_died
				}
				triggered_desc = {
					trigger = {
						scope:book_content_quality < 40
					}
					desc = fund_inspiration.1031.desc_low_content_quality
				}
				desc = fund_inspiration.1031.desc
			}
		}
		desc = artifact_book_description
	}
	theme = inspiration_complete
	override_background = { reference = study }
	left_portrait = {
		character = scope:inspiration_owner
		animation = happy_teacher
	}
	right_portrait = {
		trigger = { exists = scope:portrait_2 }
		character = scope:portrait_2
		triggered_animation = {
			trigger = {
				exists = scope:soulmate
				scope:portrait_2 = scope:soulmate
			}
			animation = flirtation_left
		}
		triggered_animation = {
			trigger = {
				exists = scope:nemesis
				scope:portrait_2 = scope:nemesis
			}
			animation = anger
		}
	}
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_character_flag = trigger_book_completion_event
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		remove_character_flag = trigger_book_completion_event
		create_artifact_book_effect = {
			OWNER = root
			CREATOR = scope:inspiration_owner
			SET_SUBJECT = flag:no #Will be handled in the effect itself
			SET_TOPIC = flag:no #Will be handled in the effect itself
		}
		if = {
			limit = {
				exists = scope:newly_created_artifact
				scope:newly_created_artifact = { has_artifact_feature = book_subject_relationship }
				exists = scope:topic
				scope:topic = flag:soulmate
				exists = scope:soulmate
			}
			scope:soulmate = {
				save_scope_as = portrait_2
			}
			save_scope_value_as = {
				name = portrait_2_soulmate
				value = yes
			}
		}
		else_if = {
			limit = {
				exists = scope:newly_created_artifact
				scope:newly_created_artifact = { has_artifact_feature = book_subject_relationship }
				exists = scope:topic
				scope:topic = flag:nemesis
				exists = scope:nemesis
			}
			scope:nemesis = {
				save_scope_as = portrait_2
			}
			save_scope_value_as = {
				name = portrait_2_nemesis
				value = yes
			}
		}
		#Inscribe your family motto
		if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_inscribe_motto_var
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_motto_written
			}
		}
		# Inscribe dedication - fund_inspiration.7001
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_a_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_a_var = {
					save_scope_as = dedication_a
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_written_a
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_b_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_b_var = {
					save_scope_as = dedication_b
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_written_b
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_var = flag:dedication_c
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_written_c
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_d_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_d_var = {
					save_scope_as = dedication_d
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_written_d
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_e_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_e_var = {
					save_scope_as = dedication_e
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_written_e
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_f_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_f_var = {
					save_scope_as = dedication_f
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_written_f
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_g1_var
					has_variable = artifact_dedication_g2_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g1_var = {
					save_scope_as = dedication_g1
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g2_var = {
					save_scope_as = dedication_g2
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_written_g
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_h_var = flag:dedication_h
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_written_h
			}
		}
	}

	option = {
		name = fund_inspiration.1031.a
		custom_tooltip = create_artifact_book_tooltip
		if = { #If you wrote about your soulmate they'll love it!
			limit = {
				exists = scope:portrait_2_soulmate
				scope:soulmate = { is_alive = yes }
			}
			scope:soulmate = {
				add_opinion = {
					target = root
					modifier = love_opinion
					opinion = 40
				}
				show_as_tooltip = {
					add_prestige = medium_prestige_gain
				}
				trigger_event = fund_inspiration.1032
			}
		}
		if = { #If you wrote about your nemesis they'll hate it!
			limit = {
				exists = scope:portrait_2_nemesis
				scope:nemesis = { is_alive = yes }
			}
			scope:nemesis = {
				add_opinion = {
					target = root
					modifier = hate_opinion
					opinion = -40
				}
				show_as_tooltip = {
					add_prestige = medium_prestige_loss
				}
				trigger_event = fund_inspiration.1033
			}
		}
	}

	after = {
		inspiration_completion_effect = yes
	}
}

# Book artifact - notification for soulmate that you wrote a book about them
# by Linnéa Thimrén
fund_inspiration.1032 = {
	type = character_event
	title = fund_inspiration.1032.t
	desc = fund_inspiration.1032.desc
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_sponsor
		animation = flirtation
	}

	immediate = {
		add_prestige = medium_prestige_gain
	}

	option = {
		name = fund_inspiration.1032.a
	}
}

# Book artifact - notification for nemesis that you wrote a book about them
# by Linnéa Thimrén
fund_inspiration.1033 = {
	type = character_event
	title = fund_inspiration.1032.t
	desc = fund_inspiration.1033.desc
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_sponsor
		animation = flirtation
	}

	immediate = {
		add_prestige = medium_prestige_loss
	}

	option = {
		name = {
			trigger = {
				OR = {
					dread >= medium_dread
					tyranny >= medium_tyranny
				}
			}
			text = fund_inspiration.1033.a_proud
		}
		name = {
			trigger = {
				NOR = {
					dread >= medium_dread
					tyranny >= medium_tyranny
				}
			}
			text = fund_inspiration.1033.a
		}
	}
}

# Weaver artifact
# by Sean Hughes
fund_inspiration.1041 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = {
		desc = fund_inspiration.1041.desc
		desc = artifact_wall_tapestry_description
	}
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_character_flag = trigger_tapestry_completion_event
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		remove_character_flag = trigger_tapestry_completion_event

		scope:inspiration_owner = {	
			if = {
				limit = { has_variable = artifact_tapestry_scene }
				var:artifact_tapestry_scene = {
					save_scope_as = tapestry_scene
				}
			}
		}
		create_artifact_tapestry_effect = {
			OWNER = root
			WEAVER = scope:inspiration_owner
		}
		#Inscribe your family motto
		if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_inscribe_motto_var
				}
				exists = scope:tapestry
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_motto_woven
			}
		}
		# Inscribe dedication - fund_inspiration.7001
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_a_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_a_var = {
					save_scope_as = dedication_a
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_a
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_b_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_b_var = {
					save_scope_as = dedication_b
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_b
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_var = flag:dedication_c
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_c
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_d_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_d_var = {
					save_scope_as = dedication_d
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_d
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_e_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_e_var = {
					save_scope_as = dedication_e
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_e
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_f_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_f_var = {
					save_scope_as = dedication_f
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_f
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_g1_var
					has_variable = artifact_dedication_g2_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g1_var = {
					save_scope_as = dedication_g1
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g2_var = {
					save_scope_as = dedication_g2
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_g
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_h_var = flag:dedication_h
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_h
			}
		}
	}

	option = {
		name = fund_inspiration.1001.a
		custom_tooltip = create_artifact_tapestry_tooltip
	}

	after = {
		inspiration_completion_effect = yes
	}
}

# Weaver banner artifact
# by Joe Parkin
fund_inspiration.1042 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = {
		desc = fund_inspiration.1042.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:target = root.dynasty }
				desc = artifact_wall_banner_dynasty_description
			}
			triggered_desc = {
				trigger = { scope:target = root.house }
				desc = artifact_wall_banner_house_description
			}
			desc = artifact_wall_banner_description
		}
	}
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_character_flag = trigger_banner_completion_event
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		remove_character_flag = trigger_banner_completion_event
		if = {
			limit = {
				scope:inspiration_owner = { has_variable = artifact_banner_type }
			}
			switch = {
				trigger = scope:inspiration_owner.var:artifact_banner_type
				flag:dynasty = {
					set_variable = banner_from_dynasty
					create_artifact_wall_banner_effect = {
						OWNER = root
						CREATOR = scope:inspiration_owner
						TARGET = root.dynasty
					}
				}
				flag:house = {
					set_variable = banner_from_house
					create_artifact_wall_banner_effect = {
						OWNER = root
						CREATOR = scope:inspiration_owner
						TARGET = root.house
					}
				}
				flag:title = {
					create_artifact_wall_banner_effect = {
						OWNER = root
						CREATOR = scope:inspiration_owner
						TARGET = root.primary_title
					}
				}
			}
			scope:inspiration_owner = { remove_variable = artifact_banner_type }
		}
		#Inscribe your family motto
		if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_inscribe_motto_var
				}
				exists = scope:tapestry
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_motto_woven
			}
		}
		# Inscribe dedication - fund_inspiration.7001
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_a_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_a_var = {
					save_scope_as = dedication_a
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_a
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_b_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_b_var = {
					save_scope_as = dedication_b
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_b
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_var = flag:dedication_c
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_c
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_d_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_d_var = {
					save_scope_as = dedication_d
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_d
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_e_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_e_var = {
					save_scope_as = dedication_e
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_e
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_f_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_f_var = {
					save_scope_as = dedication_f
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_f
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_g1_var
					has_variable = artifact_dedication_g2_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g1_var = {
					save_scope_as = dedication_g1
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g2_var = {
					save_scope_as = dedication_g2
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_g
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_h_var = flag:dedication_h
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_woven_h
			}
		}
	}

	option = {
		name = fund_inspiration.1001.a
		custom_tooltip = create_artifact_banner_tooltip
	}

	after = {
		inspiration_completion_effect = yes
	}
}

#Adventurer Returns
#By Bianca Savazzi and Linnéa Thimrén
fund_inspiration.1051 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = { 	
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:throne
				}
				desc = fund_inspiration.1051_throne.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:ark_covenant
				}
				desc = fund_inspiration.1051_ark_covenant.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:cupboard
				}
				desc = fund_inspiration.1051_cupboard.desc
			}
			desc = fund_inspiration.1051.desc
		}
		
		first_valid = {
			
			triggered_desc = {
				trigger = {
					exists = scope:throne
				}
				desc = fund_inspiration.1051.desc.epic.throne
			}
			triggered_desc = {
				trigger = {
					exists = scope:ark_covenant
				}
				desc = fund_inspiration.1051.desc.epic.ark
			}
			triggered_desc = {
				trigger = {
					exists = scope:cupboard
				}
				desc = fund_inspiration.1051.desc.epic.cupboard
			}
			triggered_desc = {
				trigger = {
					exists = scope:epic
					NOT = { exists = scope:cupboard }
					NOT = { exists = scope:ark_covenant }
					NOT = { exists = scope:throne }
				}
				desc = fund_inspiration.1051.desc.epic
			}
			triggered_desc = {
				trigger = {
					exists = scope:regalia_artifact
				}
				desc = fund_inspiration.1051.desc.regalia
			}
			triggered_desc = {
				trigger = {
					exists = scope:regalia_artifact
				}
				desc = fund_inspiration.1051.desc.regalia_2
			}
			triggered_desc = {
				trigger = {
					exists = scope:necklace_artifact
				}
				desc = fund_inspiration.1051.desc.necklace
			}
			triggered_desc = {
				trigger = {
					exists = scope:armor_artifact
				}
				desc = fund_inspiration.1051.desc.armor
			}
			triggered_desc = {
				trigger = {
					exists = scope:weapon_artifact
				}
				desc = fund_inspiration.1051.desc.weapon
			}
			triggered_desc = {
				trigger = {
					exists = scope:box
				}
				desc = fund_inspiration.1051.desc.box
			}
			triggered_desc = {
				trigger = {
					exists = scope:skull
				}
				desc = fund_inspiration.1051.desc.skull
			}
			triggered_desc = {
				trigger = {
					exists = scope:goblet
				}
				desc = fund_inspiration.1051.desc.goblet
			}
			triggered_desc = {
				trigger = {
					exists = scope:animal_hide_size
				}
				desc = fund_inspiration.1051.desc.hide
			}
			triggered_desc = {
				trigger = {
					exists = scope:tapestry
				}
				desc = fund_inspiration.1051.desc.tapestry
			}
		}
	}
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_owner
		animation = ecstasy
	}
	artifact = { # To display the artifact in the event-window
		trigger = { exists = scope:newly_created_artifact }
		target = scope:newly_created_artifact
		position = lower_right_portrait
	}

	trigger = {
		has_character_flag = trigger_adventure_completion_event
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"

		#Saving some scopes for the tooltips
		save_scope_as = actor
		scope:inspiration_owner = {
			save_scope_as = recipient
		}

		inspiration_adventure_create_artifact_effect = {
			OWNER = root
			CREATOR = scope:inspiration_owner
		}

		# Give the occasional third party in the adventurer's story a dummy gender
		random_dummy_gender_effect = yes
	}
	
	option = {
		name = fund_inspiration.1051.a
		trigger = {
			NOT = { exists = scope:ark_covenant }
		}
		# To give the right tooltip
		if = {
			limit = {
				exists = scope:skull
			}
			custom_tooltip = create_artifact_wall_animal_skull_tooltip
		}
		else_if = {
			limit = {
				exists = scope:animal_hide_size
			}
			custom_tooltip = create_artifact_small_hide_tooltip
		}
		else_if = {
			limit = {
				exists = scope:box
			}
			custom_tooltip = create_artifact_box_tooltip
		}
		else_if = {
			limit = {
				exists = scope:goblet
			}
			custom_tooltip = create_artifact_goblet_tooltip
		}
		else_if = {
			limit = {
				exists = scope:tapestry
			}
			custom_tooltip = create_artifact_tapestry_tooltip
		}
		else_if = {
			limit = { exists = scope:epic }
			custom_tooltip = create_artifact_epic_tooltip
			set_variable = {
				name = one_of_a_kind_var
				value = scope:epic
			}
		}
		else_if = {
			limit = {
				OR = {
					exists = scope:weapon_artifact
					exists = scope:armor_artifact
					exists = scope:necklace_artifact
					exists = scope:regalia_artifact
				}
			}
			custom_tooltip = create_artifact_adventure_tooltip
		}
	}

	option = {
		name = fund_inspiration.1051.b
		trigger = {
			exists = scope:ark_covenant
		}
		custom_tooltip = create_artifact_adventure_tooltip
	}

	after = {
		scope:inspiration_owner = {
			if = {
				limit = { NOT = { has_trait = adventurer } }
				add_trait = adventurer
			}
		}
		inspiration_completion_effect = yes

		# Remove the adventuring variable if the inspired character is an adventurer
		scope:inspiration_owner = {
			if = {
				limit = { has_variable = gone_adventuring }
				remove_variable = gone_adventuring
			}
			# Send them back home 
			set_location_to_default = yes
		}
		hidden_effect = {
			if = {
				limit = { exists = scope:artifact_origin }
				scope:artifact_origin =  { death = { death_reason = death_vanished }  }
			}
		}
	}
}

# Artisan artifact
# by Linnéa Thimrén
fund_inspiration.1061 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = {
		desc = fund_inspiration.1061.desc_floor_bound_artifact
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:small_box
				}
				desc = artifact_box_small_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:medium_box
				}
				desc = artifact_box_medium_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:sculpture_chest
				}
				desc = artifact_chest_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:sculpture
					faith = {
						NOR = {
							has_doctrine = tenet_aniconism
							religion = religion:islam_religion
						}
					}
				}
				desc = artifact_sculpture_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:sculpture
					faith = {
						OR = {
							has_doctrine = tenet_aniconism
							religion = religion:islam_religion
						}
					}
				}
				desc = artifact_sculpture_animal_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:sculpture_cabinet
					scope:inspiration_owner = {
						NOR = {
							artifact_use_indian_building_visuals_trigger = yes
							artifact_use_mena_building_visuals_trigger = yes
						}
					}
				}
				desc = artifact_cabinet_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:sculpture_cabinet
					scope:inspiration_owner = { artifact_use_indian_building_visuals_trigger = yes }
				}
				desc = artifact_diwan_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:sculpture_cabinet
					scope:inspiration_owner = { artifact_use_mena_building_visuals_trigger = yes }
				}
				desc = artifact_table_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:throne
				}
				desc = artifact_throne_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:armillary_sphere
				}
				desc = fp2_armillary_sphere_desc
			}
			triggered_desc = {
				trigger = { exists = scope:icon }
				desc = artifact_icon_description
			}
		}
	}
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_character_flag = trigger_artisan_completion_event
		trigger_if = {
			limit = { scope:inspiration_owner.var:artifact_artisan_type ?= flag:artisan_type_icon }
			faith_is_aniconic_trigger = no
		}
		trigger_else = { always = yes }
	}
	on_trigger_fail = {
		trigger_event = fund_inspiration.1062
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		remove_character_flag = trigger_artisan_completion_event

		switch = {
			trigger = scope:inspiration_owner.var:artifact_artisan_type 
			flag:artisan_type_chest = {
				create_artifact_chest_effect = {
					OWNER = root
					CARPENTER = scope:inspiration_owner
				}
				save_scope_value_as = {
					name = sculpture_chest
					value = yes
				}
			}
			flag:artisan_type_box = {
				hidden_effect = {
					random_list = {
						50 = {
							create_artifact_box_small_effect = {
								OWNER = root
								CARPENTER = scope:inspiration_owner
							}
							save_scope_value_as = {
								name = small_box
								value = yes
							}
						}
						50 = {
							create_artifact_box_medium_effect = {
								OWNER = root
								CARPENTER = scope:inspiration_owner
							}
							save_scope_value_as = {
								name = medium_box
								value = yes
							}
						}
					}
				}
			}
			flag:artisan_type_sculpture = {
				create_artifact_sculpture_effect = {
					OWNER = root
					SCULPTER = scope:inspiration_owner
				}
				save_scope_value_as = {
					name = sculpture
					value = yes
				}
			}
			flag:artisan_type_cabinet = {
				create_artifact_cabinet_effect = {
					OWNER = root
					CARPENTER = scope:inspiration_owner
				}
				save_scope_value_as = {
					name = sculpture_cabinet
					value = yes
				}
			}
			flag:artisan_type_throne = {
				create_artifact_throne_effect = {
					OWNER = root
					MAKER = scope:inspiration_owner
				}
				save_scope_value_as = {
					name = throne
					value = yes
				}
			}
			flag:artisan_type_scientific_apparatus = {
				create_artifact_fp2_armillary_sphere_effect = {
					OWNER = root
					MAKER = scope:inspiration_owner
				}
				save_scope_value_as = {
					name = armillary_sphere
					value = yes
				}
			}
			flag:artisan_type_urn = {
				create_artifact_urn_effect = {
					OWNER = root
					POTTER = scope:inspiration_owner
				}
				save_scope_value_as = {
					name = urn
					value = yes
				}
			}
			flag:artisan_type_icon = {
				create_artifact_icon_effect = {
					OWNER = root
					CREATOR = scope:inspiration_owner
				}
				save_scope_value_as = {
					name = icon
					value = yes
				}
			}
		}
		# Add a dedication to the description - fund_inspiration.7001
		if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_a_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_a_var = {
					save_scope_as = dedication_a
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_a
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_b_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_b_var = {
					save_scope_as = dedication_b
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_b
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_var = flag:dedication_c
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_c
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_d_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_d_var = {
					save_scope_as = dedication_d
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_d
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_e_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_e_var = {
					save_scope_as = dedication_e
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_e
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_f_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_f_var = {
					save_scope_as = dedication_f
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_f
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_g1_var
					has_variable = artifact_dedication_g2_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g1_var = {
					save_scope_as = dedication_g1
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g2_var = {
					save_scope_as = dedication_g2
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_g
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_h_var = flag:dedication_h
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_h
			}
		}
		#Inscribe your family motto
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_inscribe_motto_var
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_motto_inscribed
			}
		}
	}

	#
	option = {
		name = fund_inspiration.1001.a
		custom_tooltip = create_artifact_artisan_tooltip
	}
}

#Let's not make icons for aniconic religions
fund_inspiration.1062 = {
	hidden = yes
	trigger = {
		scope:inspiration_owner.var:artifact_artisan_type ?= flag:artisan_type_icon
		faith_is_aniconic_trigger = yes
	}
	immediate = {
		remove_character_flag = trigger_artisan_completion_event
		scope:inspiration_owner = {
			destroy_inspiration = inspiration
			remove_variable ?= artifact_artisan_type
		}
		send_interface_message = {
			type = msg_court_inspiration_neutral
			title = fund_inspiration.9001.t
			desc = fund_inspiration.9001.t
			left_icon = root
			right_icon = scope:inspiration_owner
		}
	}
}

# Smith artifact
# by Linnéa Thimrén
fund_inspiration.1071 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = {
		desc = {
			desc = fund_inspiration.1061.desc
			first_valid = {
				triggered_desc = {
					trigger = {
						exists = scope:brooch
					}
					desc = artifact_brooch_description
				}
				triggered_desc = {
					trigger = {
						exists = scope:regalia
					}
					desc = artifact_regalia_description
				}
				triggered_desc = {
					trigger = {
						exists = scope:crown
					}
					desc = artifact_crown_description
				}
				triggered_desc = {
					trigger = {
						exists = scope:goblet
					}
					desc = artifact_goblet_description
				}
				triggered_desc = {
					trigger = {
						exists = scope:aquamanile
					}
					desc = fp2_andalusian_aquamanile_desc
				}
				triggered_desc = {
					trigger = {
						exists = scope:incense_burner_sculpture
					}
					desc = fp3_incense_burner_sculpture_desc
				}
			}
			triggered_desc = {
				trigger = {
					exists = scope:crown
					has_character_flag = waiting_for_a_crown
				}
				desc = fund_inspiration.1071.coronation
			}
		}
	}
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_character_flag = trigger_smith_completion_event
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		remove_character_flag = trigger_smith_completion_event

		if = {
			limit = {
				scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_brooch
			}
			create_artifact_brooch_effect = {
				OWNER = root
				SMITH = scope:inspiration_owner
			}
			save_scope_value_as = {
				name = brooch
				value = yes
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_regalia
			}
			create_artifact_regalia_effect = {
				OWNER = root
				SMITH = scope:inspiration_owner
			}
			save_scope_value_as = {
				name = regalia
				value = yes
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_crown
			}
			create_artifact_crown_effect = {
				OWNER = root
				SMITH = scope:inspiration_owner
			}
			save_scope_value_as = {
				name = crown
				value = yes
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_goblet
			}
			random_list = {
				70 = {
					trigger = {
						has_fp3_dlc_trigger = yes
						scope:inspiration_owner = { artifact_should_use_gfx_type_trigger = { TYPE = iranian_building } }
					}
					create_artifact_persian_drinking_vessel_effect = {
						OWNER = root
						SMITH = scope:inspiration_owner
					}
				}
				30 = {
					create_artifact_goblet_effect = {
						OWNER = root
						SMITH = scope:inspiration_owner
					}
				}
			}
			save_scope_value_as = {
				name = goblet
				value = yes
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_aquamanile
			}
			create_artifact_fp2_andalusian_aquamanile_effect = {
				OWNER = root
				SMITH = scope:inspiration_owner
			}
			save_scope_value_as = {
				name = aquamanile
				value = yes
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_incense_burner_sculpture
				has_fp3_dlc_trigger = yes
			}
			create_artifact_fp3_incense_burner_sculpture_effect = {
				OWNER = root
				SMITH = scope:inspiration_owner
			}
			save_scope_value_as = {
				name = incense_burner_sculpture
				value = yes
			}
		}
		# Add a dedication to the description - fund_inspiration.7001
		if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_a_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_a_var = {
					save_scope_as = dedication_a
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_a
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_b_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_b_var = {
					save_scope_as = dedication_b
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_b
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_var = flag:dedication_c
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_c
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_d_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_d_var = {
					save_scope_as = dedication_d
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_d
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_e_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_e_var = {
					save_scope_as = dedication_e
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_e
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_f_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_f_var = {
					save_scope_as = dedication_f
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_f
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_g1_var
					has_variable = artifact_dedication_g2_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g1_var = {
					save_scope_as = dedication_g1
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g2_var = {
					save_scope_as = dedication_g2
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_g
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_h_var = flag:dedication_h
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_h
			}
		}
		#Inscribe your family motto
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_inscribe_motto_var
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_motto_inscribed
			}
		}
	}

	#
	option = {
		name = fund_inspiration.1001.a
		trigger = { NOT = { has_character_flag = waiting_for_a_crown can_host_activity = activity_coronation } }
		custom_tooltip = create_artifact_smith_tooltip
	}

	option = {
		name = fund_inspiration.1001.b	
		trigger = {
			has_ach_dlc_trigger = yes
			has_character_flag = waiting_for_a_crown
		}
		remove_character_flag = waiting_for_a_crown

		custom_tooltip = create_artifact_smith_tooltip
		custom_tooltip = fund_inspiration.1001.b.coronation_ready
		open_view_data = {
			view = activity_list_detail_host_window
			data = activity_type:activity_coronation
			player = root
		}
	}
}

# Alchemy artifact
# by Linnéa Thimrén
fund_inspiration.1081 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = {
		desc = fund_inspiration.1081.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:immortality
					scope:newly_created_artifact = {
						has_artifact_feature = elixir_youth
					}
				}
				desc = {
					desc = fund_inspiration.1081.immortality_fail_desc_opening
					first_valid = {
						triggered_desc = {
							trigger = { age < 25 }
							desc = fund_inspiration.1081.immortality_fail_desc_young
						}
						desc = fund_inspiration.1081.immortality_fail_desc_old
					}
				}
			}
			triggered_desc = {
				trigger = {
					OR = {
						exists = scope:elixirs
						exists = scope:immortality
					}
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = { age < 25 }
							desc = fund_inspiration.1081.elixir_desc_desc_young
						}
						desc = fund_inspiration.1081.elixir_desc_desc_old
					}
				}
			}
			triggered_desc = {
				trigger = {
					exists = scope:panacea
				}
				desc = fund_inspiration.1081.panacea_desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:metals
				}
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								exists = scope:philosophers_stone
							}
							desc = fund_inspiration.1081.metals_philosophers_stone_desc
						}
						triggered_desc = {
							trigger = {
								exists = scope:inspiration_owner.var:artifact_alchemy_type_metal_subtype
								scope:inspiration_owner.var:artifact_alchemy_type_metal_subtype = flag:mercury
							}
							desc = fund_inspiration.1081.metals_mercury_desc
						}
						triggered_desc = {
							trigger = {
								exists = scope:inspiration_owner.var:artifact_alchemy_type_metal_subtype
								scope:inspiration_owner.var:artifact_alchemy_type_metal_subtype = flag:arsenic
							}
							desc = fund_inspiration.1081.metals_arsenic_desc
						}
						triggered_desc = {
							trigger = {
								exists = scope:inspiration_owner.var:artifact_alchemy_type_metal_subtype
								scope:inspiration_owner.var:artifact_alchemy_type_metal_subtype = flag:gold
							}
							desc = fund_inspiration.1081.metals_gold_desc
						}
						triggered_desc = {
							trigger = {
								exists = scope:inspiration_owner.var:artifact_alchemy_type_metal_subtype
								scope:inspiration_owner.var:artifact_alchemy_type_metal_subtype = flag:silver
							}
							desc = fund_inspiration.1081.metals_silver_desc
						}
						desc = fund_inspiration.1081.metals_fallback_desc
					}
				}
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:philosophers_stone
				}
				desc = artifact_philosophers_stone_description
			}
			triggered_desc = {
				trigger = {
					OR = {
						exists = scope:elixirs
						exists = scope:immortality
					}
				}
				desc = artifact_elixir_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:metals
				}
				desc = artifact_book_description
			}
			triggered_desc = {
				trigger = {
					exists = scope:panacea
				}
				desc = artifact_panacea_description
			}
		}
	}
	theme = inspiration_complete
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_character_flag = trigger_alchemy_completion_event
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		remove_character_flag = trigger_alchemy_completion_event
		capital_province = { save_scope_as = location } #For artifact creation
		if = {
			limit = {
				scope:inspiration_owner.var:artifact_alchemy_type = flag:alchemy_type_elixirs
			}
			create_artifact_elixir_effect = {
				OWNER = root
				ALCHEMIST = scope:inspiration_owner
			}
			save_scope_value_as = {
				name = elixirs
				value = yes
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner.var:artifact_alchemy_type = flag:alchemy_type_metals
			}
			scope:inspiration_owner = {
				if = {
					limit = {
						OR = {
							has_trait = arrogant
							has_trait = ambitious
							has_trait = lunatic
						}
					}
					random = {
						chance = 1
						modifier = {
							add = 2
							has_trait = lunatic
						}
						create_artifact_philosophers_stone_effect = { OWNER = root }
						save_scope_value_as = {
							name = philosophers_stone
							value = yes
						}
					}
				}
				if = {
					limit = {
						NOT = { exists = scope:philosophers_stone } #You didn't roll success on the random above
						has_variable = artifact_alchemy_type_metal_subtype
					}
					if = {
						limit = {
							var:artifact_alchemy_type_metal_subtype = flag:mercury
						}
						set_variable = {
							name = book_topic_category #To create the book properly
							value = flag:mercury
						}
						create_artifact_book_effect = {
							OWNER = root
							CREATOR = scope:inspiration_owner
							SET_SUBJECT = flag:alchemy
							SET_TOPIC = flag:mercury
						}
						remove_variable = artifact_alchemy_type_metal_subtype
					}
					else_if = {
						limit = {
							var:artifact_alchemy_type_metal_subtype = flag:arsenic
						}
						set_variable = {
							name = book_topic_category #To create the book properly
							value = flag:arsenic
						}
						create_artifact_book_effect = {
							OWNER = root
							CREATOR = scope:inspiration_owner
							SET_SUBJECT = flag:alchemy
							SET_TOPIC = flag:arsenic
						}
						remove_variable = artifact_alchemy_type_metal_subtype
					}
					else_if = {
						limit = {
							var:artifact_alchemy_type_metal_subtype = flag:gold
						}
						set_variable = {
							name = book_topic_category #To create the book properly
							value = flag:gold
						}
						create_artifact_book_effect = {
							OWNER = root
							CREATOR = scope:inspiration_owner
							SET_SUBJECT = flag:alchemy
							SET_TOPIC = flag:gold
						}
						remove_variable = artifact_alchemy_type_metal_subtype
					}
					else_if = {
						limit = {
							var:artifact_alchemy_type_metal_subtype = flag:silver
						}
						set_variable = {
							name = book_topic_category #To create the book properly
							value = flag:silver
						}
						create_artifact_book_effect = {
							OWNER = root
							CREATOR = scope:inspiration_owner
							SET_SUBJECT = flag:alchemy
							SET_TOPIC = flag:silver
						}
						remove_variable = artifact_alchemy_type_metal_subtype
					}
					else = {
						create_artifact_book_effect = {
							OWNER = root
							CREATOR = scope:inspiration_owner
							SET_SUBJECT = flag:alchemy
							SET_TOPIC = flag:no
						}
					}
				}
				else_if = { #Fallback if you somehow have managed to not set the subtype
					limit = { NOT = { exists = scope:philosophers_stone } }
					create_artifact_book_effect = {
						OWNER = root
						CREATOR = scope:inspiration_owner
						SET_SUBJECT = flag:alchemy
						SET_TOPIC = flag:no
					}
				}
			}
			save_scope_value_as = {
				name = metals
				value = yes
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner.var:artifact_alchemy_type = flag:alchemy_type_panacea
			}
			create_artifact_panacea_effect = {
				OWNER = root
				ALCHEMIST = scope:inspiration_owner
			}
			save_scope_value_as = {
				name = panacea
				value = yes
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner.var:artifact_alchemy_type = flag:alchemy_type_immortality
			}
			create_artifact_elixir_effect = {
				OWNER = root
				ALCHEMIST = scope:inspiration_owner
			}
			save_scope_value_as = {
				name = immortality
				value = yes
			}
		}
	}

	option = {
		name = {
			trigger = {
				OR = {
					exists = scope:elixirs
					exists = scope:immortality
				}
			}
			text = fund_inspiration.1081.a_elixirs
		}
		name = {
			trigger = {
				NOR = {
					exists = scope:elixirs
					exists = scope:immortality
				}
			}
			text = fund_inspiration.1081.a
		}
		if = {
			limit = {
				OR = {
					exists = scope:elixirs
					exists = scope:immortality
				}
			}
			custom_tooltip = create_artifact_alchemy_elixir_tooltip
		}
		else_if = {
			limit = {
				exists = scope:book
			}
			custom_tooltip = create_artifact_alchemy_book_tooltip
		}
		else = {
			custom_tooltip = create_artifact_alchemy_tooltip
		}
	}
}

# Bow artifact
fund_inspiration.1091 = {
	type = character_event
	title = fund_inspiration.1001.t
	desc = {
		desc = fund_inspiration.1091.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:bow_type = flag:artifact_bow_type_longbow }
				desc = artifact_longbow_description
			}
			triggered_desc = {
				trigger = { scope:bow_type = flag:artifact_bow_type_composite }
				desc = artifact_composite_description
			}
			triggered_desc = {
				trigger = { scope:bow_type = flag:artifact_bow_type_crossbow }
				desc = artifact_crossbow_description
			}
			desc = artifact_bow_description
		}
	}
	theme = inspiration_complete
	override_background = { reference = armory }
	left_portrait = {
		character = scope:inspiration_owner
		triggered_animation = {
			trigger = { scope:bow_type = flag:artifact_bow_type_longbow }
			animation = hunting_longbow_aim_arrow_default
		}
		triggered_animation = {
			trigger = { scope:bow_type = flag:artifact_bow_type_composite }
			animation = hunting_shortbow_aim_arrow_default
		}
		triggered_animation = {
			trigger = { scope:bow_type = flag:artifact_bow_type_crossbow }
			animation = crossbow
		}
		animation = hunting_shortbow_aim_arrow_default
	}
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}

	trigger = {
		has_character_flag = trigger_bow_completion_event
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		remove_character_flag = trigger_bow_completion_event

		create_artifact_bow_effect = {
			OWNER = root
			CREATOR = scope:inspiration_owner
			SET_BOW_TYPE = flag:no #Decided in the effect based on the variable saved on the inspiration owner
		}
		# Add a dedication to the description - fund_inspiration.7001
		if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_a_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_a_var = {
					save_scope_as = dedication_a
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_a
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_b_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_b_var = {
					save_scope_as = dedication_b
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_b
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_var = flag:dedication_c
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_c
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_d_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_d_var = {
					save_scope_as = dedication_d
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_d
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_e_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_e_var = {
					save_scope_as = dedication_e
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_e
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_f_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_f_var = {
					save_scope_as = dedication_f
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_f
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_g1_var
					has_variable = artifact_dedication_g2_var
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g1_var = {
					save_scope_as = dedication_g1
				}
			}
			scope:inspiration_owner = {
				var:artifact_dedication_g2_var = {
					save_scope_as = dedication_g2
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_g
			}
		}
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_dedication_var
					var:artifact_dedication_h_var = flag:dedication_h
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_dedication_inscribed_h
			}
		}
		#Inscribe your family motto
		else_if = {
			limit = {
				scope:inspiration_owner = {
					has_variable = artifact_inscribe_motto_var
				}
			}
			scope:newly_created_artifact = {
				set_artifact_description = artifact_motto_inscribed
			}
		}
	}

	option = {
		name = fund_inspiration.1091.a
		custom_tooltip = create_artifact_bow_tooltip
	}
}

##################################################
# Inspiration invalidated
# by Linnéa Thimrén
# 9001-9999
##################################################

# The inspired character died
# by Linnéa Thimrén
fund_inspiration.9001 = {
	type = character_event
	title = fund_inspiration.9001.t
	desc = {
		desc = fund_inspiration.9001.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:weapon_inspiration
				}
				desc = fund_inspiration.9001.desc_weapon
			}
			triggered_desc = {
				trigger = {
					exists = scope:armor_inspiration
				}
				desc = fund_inspiration.9001.desc_armor
			}
			triggered_desc = {
				trigger = {
					exists = scope:book_inspiration
				}
				desc = fund_inspiration.9001.desc_book
			}
			triggered_desc = {
				trigger = {
					exists = scope:weaver_inspiration
				}
				desc = fund_inspiration.9001.desc_weaver
			}
			triggered_desc = {
				trigger = {
					exists = scope:adventure_inspiration
				}
				desc = fund_inspiration.9001.desc_adventurer
			}
			triggered_desc = {
				trigger = {
					exists = scope:artisan_inspiration
				}
				desc = fund_inspiration.9001.desc_artisan
			}
			triggered_desc = {
				trigger = {
					exists = scope:smith_inspiration
				}
				desc = fund_inspiration.9001.desc_smith
			}
			triggered_desc = {
				trigger = {
					exists = scope:alchemy_inspiration
				}
				desc = fund_inspiration.9001.desc_alchemy
			}
			triggered_desc = {
				trigger = {
					exists = scope:research_inspiration
				}
				desc = fund_inspiration.9001.desc_research
			}
		}
	}

	theme = realm
	left_portrait = scope:inspiration_owner

	trigger = {
		scope:inspiration_owner = {
			is_alive = no
		}
	}

	immediate = {
		play_music_cue = mx_cue_death
	}

	option = {
		name = fund_inspiration.9001.a
		custom_tooltip = fund_inspiration.9001.a_tt
	}
}

# The inspired character is imprisoned
# by Linnéa Thimrén
fund_inspiration.9002 = {
	type = character_event
	title = fund_inspiration.9001.t
	desc = {
		desc = fund_inspiration.9002.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:weapon_inspiration
				}
				desc = fund_inspiration.9002.desc_weapon
			}
			triggered_desc = {
				trigger = {
					exists = scope:armor_inspiration
				}
				desc = fund_inspiration.9002.desc_armor
			}
			triggered_desc = {
				trigger = {
					exists = scope:book_inspiration
				}
				desc = fund_inspiration.9002.desc_book
			}
			triggered_desc = {
				trigger = {
					exists = scope:weaver_inspiration
				}
				desc = fund_inspiration.9002.desc_weaver
			}
			triggered_desc = {
				trigger = {
					exists = scope:adventure_inspiration
				}
				desc = fund_inspiration.9002.desc_adventurer
			}
			triggered_desc = {
				trigger = {
					exists = scope:artisan_inspiration
				}
				desc = fund_inspiration.9002.desc_artisan
			}
			triggered_desc = {
				trigger = {
					exists = scope:smith_inspiration
				}
				desc = fund_inspiration.9002.desc_smith
			}
			triggered_desc = {
				trigger = {
					exists = scope:alchemy_inspiration
				}
				desc = fund_inspiration.9002.desc_alchemy
			}
			triggered_desc = {
				trigger = {
					exists = scope:research_inspiration
				}
				desc = fund_inspiration.9002.desc_research
			}
		}
	}
	theme = realm
	left_portrait = scope:inspiration_owner

	trigger = {
		scope:inspiration_owner = {
			is_imprisoned = yes
		}
	}

	immediate = {
		play_music_cue = mx_cue_death
	}

	option = {
		name = fund_inspiration.9001.a
		custom_tooltip = fund_inspiration.9001.a_tt
	}
}

# The inspired character is no longer courtier of sponsor
# by Linnéa Thimrén
fund_inspiration.9003 = {
	type = character_event
	title = fund_inspiration.9001.t
	desc = {
		desc = fund_inspiration.9003.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:weapon_inspiration
				}
				desc = fund_inspiration.9002.desc_weapon
			}
			triggered_desc = {
				trigger = {
					exists = scope:armor_inspiration
				}
				desc = fund_inspiration.9002.desc_armor
			}
			triggered_desc = {
				trigger = {
					exists = scope:book_inspiration
				}
				desc = fund_inspiration.9002.desc_book
			}
			triggered_desc = {
				trigger = {
					exists = scope:weaver_inspiration
				}
				desc = fund_inspiration.9002.desc_weaver
			}
			triggered_desc = {
				trigger = {
					exists = scope:adventure_inspiration
				}
				desc = fund_inspiration.9002.desc_adventurer
			}
			triggered_desc = {
				trigger = {
					exists = scope:artisan_inspiration
				}
				desc = fund_inspiration.9002.desc_artisan
			}
			triggered_desc = {
				trigger = {
					exists = scope:smith_inspiration
				}
				desc = fund_inspiration.9002.desc_smith
			}
			triggered_desc = {
				trigger = {
					exists = scope:alchemy_inspiration
				}
				desc = fund_inspiration.9002.desc_alchemy
			}
			triggered_desc = {
				trigger = {
					exists = scope:research_inspiration
				}
				desc = fund_inspiration.9002.desc_research
			}
		}
	}
	theme = realm
	left_portrait = scope:inspiration_owner

	trigger = {
		scope:inspiration_owner = {
			NOT = { is_courtier_of = scope:inspiration_sponsor }
		}
	}

	immediate = {
		play_music_cue = mx_cue_death
	}

	option = {
		name = fund_inspiration.9001.a
		custom_tooltip = fund_inspiration.9001.a_tt
	}
}

#Adventurer returns prematurely.

fund_inspiration.9004 = {
	type = character_event
	title = fund_inspiration.9001.t
	desc = {
		triggered_desc = {
			trigger = {
				scope:inspiration_owner = { # Add more descs if there is another reason for the adventurer to prematurely return
					has_character_flag = adventurer_stuck_in_swamp
				}
			}
			desc = fund_inspiration.9004.desc_adventurer_stuck_in_swamp
		}
		desc = fund_inspiration.9004.desc
		triggered_desc = {
			trigger = {
				scope:inspiration_owner = { # Add more descs if there is another reason for the adventurer to prematurely return
					has_character_flag = adventurer_tired_of_europe
				}
			}
			desc = fund_inspiration.9004.desc_adventurer_tired_of_europe
		}
	}
	theme = realm
	left_portrait = scope:inspiration_owner

	trigger = {
		scope:inspiration_owner = {
			OR = {
				has_character_flag = adventurer_tired_of_europe
				has_character_flag = adventurer_stuck_in_swamp
			}
		}
	}

	immediate = {
		# Move the adventurer back to their default location
		scope:inspiration_owner = {
			set_location_to_default = yes
		}
		end_inspiration_sponsorship = scope:inspiration
	}
	option = {
		name = fund_inspiration.9004.a
		custom_tooltip = fund_inspiration.9001.a_tt
		scope:inspiration_owner = {
			reverse_add_opinion = {
				target = root
				modifier = kindness_opinion
				opinion = 20
			}
		}
	}
	after = {
		scope:inspiration_owner = {
			remove_character_flag = adventurer_tired_of_europe
			remove_character_flag = adventurer_stuck_in_swamp
		}
	}
}

#Sponsorship inheritance
# by Joe Parkin

fund_inspiration.9005 = {
	type = character_event
	title = fund_inspiration.9005.t
	desc = {
		desc = fund_inspiration.9005.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					any_in_list = {
						list = inherited_inspiration_list
						count > 1
					}
				}
				desc = fund_inspiration.9005.desc_multiple
			}
			desc = fund_inspiration.9005.desc_single
		}
	}
	theme = realm
	override_background = { reference = study }
	left_portrait = scope:inherited_insp_owner
	
	trigger = {
		age >= 10
		has_royal_court = yes
		any_in_list = {
			list = inherited_inspiration_list
			count >= 1
			NOT = { has_inspiration_type = adventure_inspiration }
		}
	}

	immediate = {
		ordered_in_list = {
			list = inherited_inspiration_list
			limit = {
				NOT = { has_inspiration_type = adventure_inspiration }
			}
			order_by = inspiration_gold_invested
			inspiration_owner = { save_scope_as = inherited_insp_owner }
		}
	}

	option = {
		name = fund_inspiration.9005.a
		custom_tooltip = inherited_inspiration_continue_tt
	}

	option = {
		name = fund_inspiration.9005.b
		every_in_list = {
			list = inherited_inspiration_list
			limit = {
				NOT = { has_inspiration_type = adventure_inspiration }
			}
			root = { end_inspiration_sponsorship = prev }
			inspiration_owner = {
				add_opinion = {
					target = root
					modifier = disappointed_opinion
					opinion = -10
				}
			}
		}
		custom_tooltip = inherited_inspiration_end_tt
	}
}

##################################################
# Ongoing inspiration events
# by Linnéa Thimrén
# 2001-9000
##################################################

# Check used to make sure you're not currently on cooldown for inspiration events (so that we don't spam the player)
# Has to be used in the inspiration_owner's scope!
scripted_trigger has_no_inspiration_event_cooldown = {
	NOR = {
		has_character_flag = fund_weapon_inspiration_event_cooldown
		has_character_flag = fund_armor_inspiration_event_cooldown
		has_character_flag = fund_book_inspiration_event_cooldown
		has_character_flag = fund_weaver_inspiration_event_cooldown
		has_character_flag = fund_adventure_inspiration_event_cooldown
		has_character_flag = fund_artisan_inspiration_event_cooldown
		has_character_flag = fund_smith_inspiration_event_cooldown
		has_character_flag = fund_alchemy_inspiration_event_cooldown
		has_character_flag = fund_research_inspiration_event_cooldown
	}
}

# Effect to add appropriate cooldown flag based on the inspiration type
# Has to be used in the inspiration_owner's scope!
scripted_effect add_inspiration_cooldown_flag = {
	if = {
		limit = {
			inspiration = { has_inspiration_type = weapon_inspiration }
		}
		add_character_flag = {
			flag = fund_weapon_inspiration_event_cooldown
			days = { 30 60 }
		}
	}
	else_if = {
		limit = {
			inspiration = { has_inspiration_type = armor_inspiration }
		}
		add_character_flag = {
			flag = fund_armor_inspiration_event_cooldown
			days = { 30 60 }
		}
	}
	else_if = {
		limit = {
			inspiration = { has_inspiration_type = book_inspiration }
		}
		add_character_flag = {
			flag = fund_book_inspiration_event_cooldown
			days = { 30 60 }
		}
	}
	else_if = {
		limit = {
			inspiration = { has_inspiration_type = weaver_inspiration }
		}
		add_character_flag = {
			flag = fund_weaver_inspiration_event_cooldown
			days = { 30 60 }
		}
	}
	else_if = {
		limit = {
			inspiration = { has_inspiration_type = adventure_inspiration }
		}
		add_character_flag = {
			flag = fund_adventure_inspiration_event_cooldown
			days = { 30 60 }
		}
	}
	else_if = {
		limit = {
			inspiration = { has_inspiration_type = artisan_inspiration }
		}
		add_character_flag = {
			flag = fund_artisan_inspiration_event_cooldown
			days = { 30 60 }
		}
	}
	else_if = {
		limit = {
			inspiration = { has_inspiration_type = smith_inspiration }
		}
		add_character_flag = {
			flag = fund_smith_inspiration_event_cooldown
			days = { 30 60 }
		}
	}
	else_if = {
		limit = {
			inspiration = { has_inspiration_type = alchemy_inspiration }
		}
		add_character_flag = {
			flag = fund_alchemy_inspiration_event_cooldown
			days = { 30 60 }
		}
	}
	else_if = {
		limit = {
			inspiration = { has_inspiration_type = research_inspiration }
		}
		add_character_flag = {
			flag = fund_research_inspiration_event_cooldown
			days = { 30 60 }
		}
	}
	else_if = {
		limit = {
			inspiration = { has_inspiration_type = bow_inspiration }
		}
		add_character_flag = {
			flag = fund_bow_inspiration_event_cooldown
			days = { 30 60 }
		}
	}
}


# Inspiration owner asks for more money
# by Linnéa Thimrén
fund_inspiration.2001 = {
	type = character_event
	title = fund_inspiration.2001.t
	desc = fund_inspiration.2001.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = beg
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			is_available_ai_adult = yes
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			NOT = { has_character_flag = had_event_fund_inspiration_2001 }
			NOT = { has_character_flag = local_artisan } # Should not trigger if you commissioned the artifact
			has_no_inspiration_event_cooldown = yes
			NOT = { exists = var:artifact_armor_type } #Armor has it's own event (fund_inspiration.2021)
		}
		scope:inspiration = {
			NOT = { has_inspiration_type = adventure_inspiration } #Doesn't really make sense for them to come asking for money once they are out adventuring
			inspiration_progress > 1 # To prevent the inspired character from asking for gold immediately
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			scope:inspiration_owner = {
				ai_greed >= medium_positive_greed
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2001
				years = 20
			}
			add_inspiration_cooldown_flag = yes
		}
	}

	option = { # Sure, have the money
		name = fund_inspiration.2001.a
		if = { #To make sure that the inspiration hasn't been removed
			limit = {
				exists = scope:inspiration
			}
			scope:inspiration = {
				invest_gold = 50
			}
			scope:inspiration_owner = {
				change_artifact_quality_effect = {
					AMOUNT = 4
				}
			}
			if = {
				limit = {
					scope:inspiration = {
						has_inspiration_type = book_inspiration
					}
				}
				scope:inspiration_owner = {
					change_artifact_book_content_quality_effect = {
						AMOUNT = 2
					}
				}
			}
		}
		stress_impact = {
			generous = medium_stress_impact_loss
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -50
				short_term_gold < 50
			}
		}
	}

	option = { #No!
		name = fund_inspiration.2001.b
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -20
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.75
			}
		}
	}
}

# Inspiration owner asks for more... human materials
# by Bianca Savazzi
scripted_effect payment_to_improve_quality_fund_inspiration_2002_scripted_effect = {
	if = { #To make sure that the inspiration hasn't been removed
		limit = { exists = scope:inspiration }
		scope:inspiration = {
			invest_gold = 50
		}
		improve_quality_fund_inspiration_2002_scripted_effect = yes
	}
}

scripted_effect improve_quality_fund_inspiration_2002_scripted_effect = {
	if = { #To make sure that the inspiration hasn't been removed
		limit = {
			exists = scope:inspiration
			scope:inspiration = { has_inspiration_type = book_inspiration }
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = 4 }
			change_artifact_book_content_quality_effect = { AMOUNT = 4 }
		}
	}
}

fund_inspiration.2002 = {
	type = character_event
	title = fund_inspiration.2002.t
	desc = {
		desc = fund_inspiration.2002.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						scope:inspiration_owner.var:book_subject = flag:medicine
						scope:inspiration_owner.var:book_subject = flag:cannibal
						scope:inspiration_owner.var:book_subject = flag:torturer
						AND = {
							exists = scope:inspiration_owner.var:book_topic_category
							scope:inspiration_owner.var:book_topic_category = flag:intrigue_scheme
						}
						AND = {
							exists = scope:inspiration_owner.var:book_topic
							scope:inspiration_owner.var:book_topic = flag:punishment
						}
					}
					NOT = { has_trait = blind }
				}
				desc = fund_inspiration.2002.desc.fingernails
			}
			triggered_desc = {
				trigger = {
					OR = {
						scope:inspiration_owner.var:book_subject = flag:witch
						scope:inspiration_owner.var:book_subject = flag:herbalist
					}
					NOT = { has_trait = blind }
				}
				desc = fund_inspiration.2002.desc.potions
			}
			desc = fund_inspiration.2002.desc.blind # Fallback & blind version
		}
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = schadenfreude
	}

	trigger = {
		exists = scope:inspiration
		is_adult = yes
		scope:inspiration_owner = {
			is_available_ai_adult = yes
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			NOT = { has_character_flag = had_event_fund_inspiration_2002 }
			has_no_inspiration_event_cooldown = yes
			exists = var:book_subject
		}

		OR = {
			scope:inspiration_owner.var:book_subject = flag:medicine
			scope:inspiration_owner.var:book_subject = flag:cannibal
			scope:inspiration_owner.var:book_subject = flag:torturer
			AND = {
				exists = scope:inspiration_owner.var:book_topic_category
				scope:inspiration_owner.var:book_topic_category = flag:intrigue_scheme
			}
			AND = {
				exists = scope:inspiration_owner.var:book_topic
				scope:inspiration_owner.var:book_topic = flag:punishment
			}
			scope:inspiration_owner.var:book_subject = flag:witch
			scope:inspiration_owner.var:book_subject = flag:herbalist
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			scope:inspiration_owner = {
				has_trait = sadistic
			}
		}

		# Based on ai_rationality (Only highly irrational characters should even consider this option)
		modifier = {
			add = {
				scope:inspiration_owner = {
					value = ai_rationality
					if = {
						limit = {
							has_trait = wrathful
						}
						subtract = medium_negative_ai_value # Though Wrathful does has a low ai_rationality score, that's not *quite* the personality we're looking for here.
					}
					if = {
						limit = {
							has_trait = paranoid
						}
						subtract = medium_negative_ai_value # Same goes for Paranoid
					}
					if = {
						limit = {
							OR = {
								has_trait = arbitrary
								has_trait = fickle
							}
						}
						add = low_negative_ai_value # Arbitrary and/or fickle characters are more likely to entertain this than their 'ai_rationality' would suggest.
					}
					multiply = -5
				}
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2002
				years = 20
			}
			add_inspiration_cooldown_flag = yes
		}

		# Check and save prisoner for option A
		if = {
			limit = {
				any_prisoner = {
					is_adult = yes
					is_in_prison_type = dungeon
					is_imprisoned_by = root
				}
			}
			random_prisoner = {
				limit = {
					is_adult = yes
					is_in_prison_type = dungeon
					is_imprisoned_by = root
				}
				save_scope_as = prisoner_for_material
			}
		}
	
		#Check and save the scope of a foreign neighbouring county for option C
		if = { 
			limit = {
				exists = capital_county #safety check that character is landed
				capital_county = { holder = root }
			}
		
			capital_county = {
				if = {
					limit = {
						any_neighboring_county = {
							holder = { 	
								NOT = { this = root } 
								liege = { NOT = { this = root } }
								is_ai = yes
							}
						}
					}
					
					random_neighboring_county = {
						limit = {
							holder = { 	
								is_ai = yes
								NOT = { this = root } 
								liege = { NOT = { this = root } }
							}
						}
						save_scope_as = neighbouring_county_for_material
					}
				}
			}
		}
	}

	option = { # use prisoners in dungeon
		name = fund_inspiration.2002.a
		trigger = {
			exists = scope:prisoner_for_material
		}

		execute_prisoner_effect = {
			VICTIM = scope:prisoner_for_material
			EXECUTIONER = scope:inspiration_owner
		}
		improve_quality_fund_inspiration_2002_scripted_effect = yes

		ai_chance = {
			base = 50
			modifier = {
				add = 25
				has_trait = torturer #torturers are happy to cause more misery 
			}
			modifier = {
				add = 25
				OR = {
					has_trait = sadistic
					ai_compassion <= low_negative_compassion
 				}
			}
			modifier = {
				add = -25
				ai_compassion >= low_positive_compassion
			}
			modifier = {
				add = -50
				ai_compassion >= medium_positive_compassion
			}
		}
	}

	option = { #some money to kidnap 
		name = fund_inspiration.2002.b

		payment_to_improve_quality_fund_inspiration_2002_scripted_effect = yes

		capital_county = {
			add_county_modifier = {
				modifier = fund_inspiration_missing_peasants_modifier
				years = 15
			}
		}

		ai_chance = {
			base = 50
			modifier = {
				add = 25
				has_trait = arrogant #views others, esp peasants, as lower than them
			}
			modifier = {
				add = 25
				OR = {
					has_trait = sadistic
					ai_compassion <= low_negative_compassion
 				}
			}
			modifier = {
				add = -25
				has_trait = greedy #this option costs money... money that look better in my coffers...
			}
			modifier = {
				add = -25
				ai_compassion >= low_positive_compassion
			}
			modifier = {
				add = -50
				ai_compassion >= medium_positive_compassion
			}
		} 
	}

	option = { #kidnap some foreign peasants
		name = fund_inspiration.2002.c
		trigger = {
			exists = scope:neighbouring_county_for_material
		}

		scope:neighbouring_county_for_material = {
			add_county_modifier = {
				modifier = fund_inspiration_missing_peasants_modifier
				years = 15
			}
			holder = {
				duel = {
					skill = intrigue
					target = root
					10 = {
						desc = fund_inspiration.2002.toast_outcome.positive
						send_interface_toast = {
							title = fund_inspiration.2002.toast_outcome.positive
							left_icon = scope:neighbouring_county_for_material.holder
						}
					}
					10 = {
						desc = fund_inspiration.2002.toast_outcome.negative
						send_interface_toast = {
							title = fund_inspiration.2002.toast_outcome.negative
							left_icon = scope:neighbouring_county_for_material.holder
							scope:neighbouring_county_for_material.holder = {
								progress_towards_rival_effect = {
									REASON = rival_kidnapped_peasants
									CHARACTER = root
									OPINION = -50
								}
							}
						}
					}
				}
			}
		}
		payment_to_improve_quality_fund_inspiration_2002_scripted_effect = yes
		ai_chance = {
			base = 50
			modifier = {
				add = 25
				OR = {
  					has_trait = sadistic
 					ai_compassion <= low_negative_compassion
				}
			}
			modifier = {
				add = -25
				has_trait = just #it's not right to involve another country's peasants in this
			}
			modifier = {
				add = -25
				has_trait = diplomat #this is a recipe for a diplomatic disaster
			}
			modifier = {
				add = -25
				ai_compassion >= low_positive_compassion
			}
			modifier = {
				add = -50
				ai_compassion >= medium_positive_compassion
			}
		}
	}

	option = { #No!
		name = fund_inspiration.2002.d

		ai_chance = {
			base = 50
			modifier = {
				add = 25
				ai_compassion >= low_positive_compassion
			}
			modifier = {
				add = 50
				ai_compassion >= medium_positive_compassion
			}
			modifier = {
				add = 25
				faith = {
 					has_doctrine_parameter = pacifist_opinion_active
 				}
			}
		}
	}
}

# Previously inspiration owner is bothering the current one in their creation
# by Bianca Savazzi
fund_inspiration.2003 = {
	type = character_event
	title = fund_inspiration.2003.t
	desc = fund_inspiration.2003.desc

	theme = realm
	override_background = {
		reference = courtyard
	}
	left_portrait = {
		character = scope:inspiration_owner
		animation = dismissal
	}

	right_portrait = {
		character = scope:previous_inspired
		animation = beg
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			is_available_ai_adult = yes
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			NOT = { has_character_flag = had_event_fund_inspiration_2003 }
			NOT = { has_character_flag = local_artisan }
			has_no_inspiration_event_cooldown = yes
			inspiration = { #Since they're away adventuring
				NOT = { has_inspiration_type = adventure_inspiration }
			}
		}
		any_courtier = {
			NOT = { this = scope:inspiration_owner }
			is_available_ai_adult = yes
			has_completed_inspiration = yes
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2003
				years = 20
			}
			add_inspiration_cooldown_flag = yes
		}

		random_courtier = {
			limit = {
				NOT = { this = scope:inspiration_owner }
				is_available_ai_adult = yes
				has_completed_inspiration = yes
			}
			weight = {
				base = 1
				modifier = {
					add = 2
					is_of_major_interest_to_root_trigger = yes
				}
				modifier = {
					add = 1
					is_of_minor_interest_to_root_trigger = yes
				}
			}
			save_scope_as = previous_inspired
		}
	}

	#You try to convince them to listen
	option = { 
		name = fund_inspiration.2003.a
		
		duel = {
			skill = diplomacy
			target = scope:inspiration_owner
			10 = {
				desc = fund_inspiration.2003.toast_outcome.positive
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				send_interface_toast = {
					title = fund_inspiration.2003.toast_outcome.positive
					left_icon = root
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = 2 }
					}
				}
			}
			20 = {
				desc = fund_inspiration.2003.toast_outcome.refusal
				send_interface_toast = {
					title = fund_inspiration.2003.toast_outcome.refusal
					left_icon = root
					scope:inspiration_owner = {
						progress_towards_rival_effect = {
							REASON = rival_dispute_inspiration
							CHARACTER = root
							OPINION = 0
						}
						progress_towards_rival_effect = {
							CHARACTER = scope:previous_inspired
							REASON = rival_dispute_inspiration
							OPINION = -30
						}
					}
				}
			}
		}

		ai_chance = {
			base = 50
			modifier = {
				add = -25
 				ai_compassion <= low_negative_compassion
			}
			modifier = {
				add = -25
 				has_trait = shy #don't wanna talk...
			}
			modifier = {
				add = 25
				OR = {
					has_trait = diplomat #let's talk things out
					has_trait = gregarious
					has_trait = patient
					AND = {
						has_education_diplomacy_trigger = yes
						diplomacy > medium_skill_rating
					}
				}
			}
			modifier = {
				add = 25
				ai_compassion >= low_positive_compassion
			}
		}
	}

	#You give feedback on their feedback
	option = {  
		name = fund_inspiration.2003.b

		duel = {
			skill = learning
			target = scope:previous_inspired
			10 = {
				desc = fund_inspiration.2003.toast_outcome.positive
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				send_interface_toast = {
					title = fund_inspiration.2003.toast_outcome.positive
					left_icon = root
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = 2 }
					}
				}
			}
			20 = {
				desc = fund_inspiration.2003.toast_outcome.negative
				send_interface_toast = {
					title = fund_inspiration.2003.toast_outcome.negative
					left_icon = root
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = -2 }
					}
				}
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -15
 				ai_rationality <= low_negative_ai_value
			}
			modifier = {
				add = 25
				OR = {
					has_trait = scholar #smart
					AND = {
						has_education_learning_trigger = yes
						learning > medium_skill_rating
					}
				}
			}
			modifier = {
				add = 25
				ai_rationality >= low_positive_ai_value
			}
		}
	}

	# Tell them off
	option = { 
		name = fund_inspiration.2003.c
		scope:previous_inspired = {
			progress_towards_rival_effect = {
				REASON = rival_dispute_inspiration
				CHARACTER = scope:inspiration_owner
				OPINION = 0
			}
			add_opinion = {
				target = root
				modifier = insult_opinion
				opinion = -20
			}
		}
		progress_towards_friend_effect = {
			CHARACTER = scope:inspiration_owner
			OPINION = 30
			REASON = friend_new_inspiration_owner
		}
		
		stress_impact = {
			wrathful = medium_stress_loss
			irritable = medium_stress_loss
			shy = minor_stress_gain
			compassionate = medium_stress_gain
		}

		ai_chance = {
			base = 50
			modifier = {
				add = 15
 				ai_rationality <= low_negative_ai_value
			}
			modifier = {
				add = 15
				ai_compassion <= low_negative_compassion
			}
			modifier = {
				add = 25
				OR = {
					has_trait = wrathful
					has_trait = callous
					has_trait = irritable
					has_trait = impatient
				}
			}
			modifier = {
				add = 25
				ai_rationality >= low_positive_ai_value
			}
		}	
	}
}

# A merchant selling high-quality materials is in town
# by Linnéa Thimrén
fund_inspiration.2004 = {
	type = character_event
	title = fund_inspiration.2004.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					# For artifacts that use metal in some way
					scope:inspiration = {
						OR = {
							has_inspiration_type = weapon_inspiration
							has_inspiration_type = smith_inspiration
							has_inspiration_type = armor_inspiration
						}
					}
				}
				desc = fund_inspiration.2004.desc_metal
			}
			triggered_desc = {
				trigger = {
					# For artifacts that use fabric in some way
					scope:inspiration = {
						OR = {
							AND = {
								has_inspiration_type = smith_inspiration
								exists = scope:inspiration_owner.var:artifact_smith_type
								scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_regalia
							}
							AND = {
								has_inspiration_type = armor_inspiration
								exists = scope:inspiration_owner.var:artifact_armor_type
								OR = { #All armor that mentions fabric in some way in their descriptions
									scope:inspiration_owner.var:artifact_armor_type = flag:armor_type_lamellar
									scope:inspiration_owner.var:artifact_armor_type = flag:armor_type_laminar
									scope:inspiration_owner.var:artifact_armor_type = flag:armor_type_brigandine
								}
							}
						}
					}
				}
				desc = fund_inspiration.2004.desc_fabric
			}
			triggered_desc = {
				trigger = {
					# For artifacts that use thread in some way
					scope:inspiration = {
						OR = {
							has_inspiration_type = weaver_inspiration
							AND = {
								has_inspiration_type = armor_inspiration
								exists = scope:inspiration_owner.var:artifact_armor_type
								scope:inspiration_owner.var:artifact_armor_type = flag:armor_type_brigandine
							}
							AND = {
								has_inspiration_type = smith_inspiration
								exists = scope:inspiration_owner.var:artifact_smith_type
								scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_regalia
							}
						}
					}
				}
				desc = fund_inspiration.2004.desc_thread
			}
			triggered_desc = {
				trigger = {
					scope:inspiration = {
						has_inspiration_type = artisan_inspiration
						inspiration_owner.var:artifact_artisan_type ?= flag:artisan_type_icon
					}
				}
				desc = fund_inspriation.2004.desc_paint
			}
			triggered_desc = {
				trigger = {
					scope:inspiration = { has_inspiration_type = artisan_inspiration }
				}
				desc = fund_inspiration.2004.desc_wood
			}
			triggered_desc = {
				trigger = {
					scope:inspiration = { has_inspiration_type = book_inspiration }
				}
				desc = {
					random_valid = {
						desc = fund_inspiration.2004.desc_paper
						desc = fund_inspiration.2004.desc_ink
					}
				}
			}
			triggered_desc = {
				trigger = {
					scope:inspiration = {
						has_inspiration_type = alchemy_inspiration
						exists = scope:inspiration_owner.var:artifact_alchemy_type
						scope:inspiration_owner.var:artifact_alchemy_type = flag:alchemy_type_metals
					}
				}
				desc = fund_inspiration.2004.desc_alchemy_metal
			}
			triggered_desc = {
				trigger = {
					scope:inspiration = {
						has_inspiration_type = alchemy_inspiration
						exists = scope:inspiration_owner.var:artifact_alchemy_type
						scope:inspiration_owner.var:artifact_alchemy_type = flag:alchemy_type_elixirs
					}
				}
				desc = fund_inspiration.2004.desc_elixirs
			}
			desc = fund_inspiration.2004.desc_fallback
		}
		desc = fund_inspiration.2004.desc
	}
	theme = realm
	override_background = {
		reference = market
	}
	left_portrait = {
		character = scope:inspiration_owner
		animation = beg
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			is_available_ai_adult = yes
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			NOT = { has_character_flag = had_event_fund_inspiration_2004 }
			NOT = { has_character_flag = local_artisan }
			has_no_inspiration_event_cooldown = yes
			inspiration = { #Since they're away adventuring
				NOT = { has_inspiration_type = adventure_inspiration }
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2004
				years = 20
			}
			add_inspiration_cooldown_flag = yes
		}
	}

	# Give them the money
	option = {
		name = fund_inspiration.2004.a
		scope:inspiration = {
			invest_gold = root.medium_gold_value
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = 4 }
			add_opinion = {
				target = root
				modifier = kindness_opinion
				opinion = 20
			}
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
			generous = medium_stress_impact_loss
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.25
			}
			modifier = {
				factor = 0
 				short_term_gold < medium_gold_value
			}
		}
	}

	# Haggle with the merchant
	option = {
		name = fund_inspiration.2004.b
		duel = {
			skill = diplomacy
			value = 10
			15 = {
				desc = fund_inspiration.2004.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				#We need to mess around with hidden effects and tooltips a bit here to not show "higher quality" twice on the option
				show_as_tooltip = {
					scope:inspiration = {
						invest_gold = root.tiny_gold_value
					}
				}
				hidden_effect = {
					send_interface_toast = {
						title = fund_inspiration.2004.b.success
						left_icon = scope:inspiration_owner
						scope:inspiration = {
							invest_gold = root.tiny_gold_value
						}
						scope:inspiration_owner = {
							change_artifact_quality_effect = { AMOUNT = 4 }
						}
					}
				}
			}
			20 = {
				desc = fund_inspiration.2004.b.failure
				#We need to mess around with hidden effects and tooltips a bit here to not show "higher quality" twice on the option
				show_as_tooltip = {
					scope:inspiration = {
						invest_gold = root.medium_gold_value
					}
					add_prestige = medium_prestige_loss
				}
				hidden_effect = {
					send_interface_toast = {
						title = fund_inspiration.2004.b.failure
						left_icon = scope:inspiration_owner
						scope:inspiration = {
							invest_gold = root.medium_gold_value
						}
						add_prestige = medium_prestige_loss
						scope:inspiration_owner = {
							change_artifact_quality_effect = { AMOUNT = 4 }
						}
					}
				}
			}
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = 4 }
			add_opinion = {
				target = root
				modifier = kindness_opinion
				opinion = 20
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.25
			}
			modifier = {
				add = 25
 				diplomacy >= high_skill_rating
			}
			modifier = {
				factor = 0
 				short_term_gold < medium_gold_value
			}
		}
	}

	# Take it by force
	option = {
		name = fund_inspiration.2004.c
		trigger = {
			is_landless_adventurer = no
		}
		add_tyranny = medium_tyranny_gain
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = 4 }
		}
		stress_impact = {
			compassionate = major_stress_impact_gain
			sadistic = medium_stress_impact_loss
			wrathful = medium_stress_impact_loss
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = -0.25
				ai_greed = 0.15
				ai_vengefulness = 0.25
			}
		}	
	}

	# Deny them
	option = { 
		name = fund_inspiration.2004.d
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -15
			}
		}
		stress_impact = {
			generous = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			sadistic = minor_stress_impact_loss
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = -0.25
				ai_greed = 0.5
			}
		}	
	}
}

#Smith (weapon/armor/smith) asks you to invest in a better forge
# by Linnéa Thimrén
fund_inspiration.2005 = {
	type = character_event
	title = fund_inspiration.2005.t
	desc = {
		desc = fund_inspiration.2005.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:inspiration = { has_inspiration_type = weapon_inspiration }
				}
				desc = fund_inspiration.2005.desc_weapon
			}
			triggered_desc = {
				trigger = {
					scope:inspiration = { has_inspiration_type = armor_inspiration }
				}
				desc = fund_inspiration.2005.desc_armor
			}
			triggered_desc = {
				trigger = {
					scope:inspiration = { has_inspiration_type = smith_inspiration }
				}
				desc = fund_inspiration.2005.desc_smith
			}
		}
		desc = fund_inspiration.2005.desc_ending
	}
	theme = realm
	override_background = {
		reference = armory
	}
	left_portrait = {
		character = scope:inspiration_owner
		animation = beg
	}

	trigger = {
		is_landless_adventurer = no
		exists = scope:inspiration
		scope:inspiration = {
			OR = {
				AND = {
					has_inspiration_type = weapon_inspiration
					exists = scope:inspiration_owner.var:artifact_weapon_type
				}
				AND = {
					has_inspiration_type = armor_inspiration
					exists = scope:inspiration_owner.var:artifact_armor_type
				}
				AND = {
					has_inspiration_type = smith_inspiration
					exists = scope:inspiration_owner.var:artifact_smith_type
				}
			}
			inspiration_owner = {
				is_available_ai_adult = yes
				has_no_inspiration_event_cooldown = yes
				NOT = { has_character_flag = had_event_fund_inspiration_2005 }
				NOT = { has_character_flag = local_artisan }
			}
			inspiration_progress > 1 # To prevent the inspired character from asking for gold immediately
			scope:inspiration_sponsor = {
				NOT = {
					has_character_modifier = inspiration_invested_in_new_forge_modifier
				}
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2005
				years = 20
			}
			#To stagger any following events
			add_inspiration_cooldown_flag = yes
		}
	}

	#Invest in a new forge
	option = {
		name = fund_inspiration.2005.a
		scope:inspiration = { invest_gold = 50 }
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = 4 }
		}
		add_character_modifier = {
			modifier = inspiration_invested_in_new_forge_modifier
			years = 5
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
			}
			modifier = { #If the AI can't afford it they should go for it
				factor = 0
				short_term_gold < 50
			}
		}
	}

	#No
	option = {
		name = fund_inspiration.2005.b
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -15
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 0.5
			}
		}
	}
}

# A wise person comes to visit, should they teach you or your inspiration owner?
# by Linnéa Thimrén
fund_inspiration.2006 = {
	type = character_event
	title = fund_inspiration.2006.t
	desc = fund_inspiration.2006.desc
	theme = realm
	left_portrait = scope:scholar_character
	right_portrait = scope:inspiration_owner

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			OR = {
				has_inspiration_type = book_inspiration
				has_inspiration_type = alchemy_inspiration
			}
			inspiration_owner = {
				is_available_ai_adult = yes
				has_no_inspiration_event_cooldown = yes
				NOT = { has_character_flag = had_event_fund_inspiration_2006 }
			}
		}
	}

	weight_multiplier = {
		base = 0.75
		modifier = { #More likely that they stop by if you have a cool court
			add = 0.5
			has_royal_court = yes
			court_grandeur_current_level > 5
		}
		modifier = { #Most likely that they stop by if you have a VERY cool court
			add = 0.5
			has_royal_court = yes
			court_grandeur_current_level > 7
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2006
				years = 20
			}
			#To stagger any following events
			add_inspiration_cooldown_flag = yes
		}
		create_character = {
			location = root.capital_province
			template = scholar_character
			save_scope_as = scholar_character
		}
	}

	#Teach inspiration owner
	option = {
		name = fund_inspiration.2006.a
		remove_short_term_gold = minor_gold_value
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = 4 }
			add_opinion = {
				target = root
				modifier = kindness_opinion
				opinion = 20
			}
			add_learning_skill = 1
		}
		scope:scholar_character = { silent_disappearance_effect = yes }
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.25
			}
			modifier = { #If the AI can't afford it they shouldn't go for it
				factor = 0
				short_term_gold < minor_gold_value
			}
		}
	}

	#Teach me!
	option = {
		name = fund_inspiration.2006.b
		remove_short_term_gold = minor_gold_value
		add_courtier = scope:scholar_character
		set_relation_mentor = scope:scholar_character
		add_learning_lifestyle_xp = major_lifestyle_xp
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.25
			}
			modifier = { #If the AI can't afford it they shouldn't go for it
				factor = 0
				short_term_gold < minor_gold_value
			}
		}
	}

	#Go away
	option = {
		name = fund_inspiration.2006.c
		scope:scholar_character = { silent_disappearance_effect = yes }
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}
		ai_chance = {
			base = 1
		}
	}
}

# Inspiration owner asks for more money (armor specific)
# by Linnéa Thimrén
fund_inspiration.2021 = {
	type = character_event
	title = fund_inspiration.2001.t
	desc = fund_inspiration.2021.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = beg
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			is_available_ai_adult = yes
			NOR = { #These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
				has_character_flag = had_event_fund_inspiration_2021
				has_character_flag = fund_armor_inspiration_event_cooldown
			}
			NOT = { has_character_flag = local_artisan }
			exists = var:artifact_armor_type
		}
		scope:inspiration = {
			inspiration_progress > 1 # To prevent the inspired character from asking for gold immediately
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.5
			scope:inspiration_owner = {
				ai_greed >= medium_positive_greed
			}
		}
		modifier = {
			add = 4 #Very likely if it's plate or lamellar armor since they were very expensive to make
			scope:inspiration_owner = {
				OR = {
					var:artifact_armor_type = flag:armor_type_plate
					var:artifact_armor_type = flag:armor_type_lamellar
				}
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2021
				years = 20
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_armor_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
	}

	option = { # Sure, have the money
		name = fund_inspiration.2021.a
		if = { #To make sure that the inspiration hasn't been removed
			limit = {
				exists = scope:inspiration
			}
			scope:inspiration = {
				invest_gold = 50
			}
			scope:inspiration_owner = {
				change_artifact_quality_effect = {
					AMOUNT = 4
				}
			}
		}
		stress_impact = {
			generous = medium_stress_impact_loss
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -50
				short_term_gold < 50
			}
		}
	}

	option = { #No!
		name = fund_inspiration.2021.b
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -20
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.75
			}
		}
	}
}

scripted_trigger fund_inspiration_court_relation_trigger = {
	is_available_ai_adult = yes
	NOT = { this = scope:inspiration_owner }
	is_in_the_same_court_as_or_guest = root
}

scripted_trigger fund_inspiration_court_inspiration_owner_trigger = {
	is_available_ai_adult = yes
	inspiration = { #Since they're away adventuring
		NOT = { has_inspiration_type = adventure_inspiration }
	}
}

# Friend helps your sponsee
# by Jose Parkin
fund_inspiration.2030 = {
	type = character_event
	title = fund_inspiration.2030.t
	desc = fund_inspiration.2030.desc
	theme = realm
	override_background = {
		reference = corridor_day
	}
	left_portrait = {
		character = scope:friend
		animation = admiration
	}
	lower_right_portrait = scope:inspiration_owner
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			inspiration = {
				NOT = { has_inspiration_type = alchemy_inspiration } # Science is not based on opinion
			}
			NOT = { has_character_flag = had_event_fund_inspiration_2030 }
		}
		any_relation = {
			type = friend
			fund_inspiration_court_relation_trigger = yes
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2030
				years = 5
			}
			add_inspiration_cooldown_flag = yes
		}
		random_relation = {
			type = friend
			limit = { fund_inspiration_court_relation_trigger = yes }
			save_scope_as = friend
			progress_towards_friend_effect = { CHARACTER = scope:inspiration_owner REASON = friend_helped_inspiration OPINION = default_friend_opinion }
		}
		scope:inspiration_owner = {
			random_list = {
				2 = {
					change_artifact_quality_effect = { AMOUNT = 3 }
				}
				2 = {
					change_artifact_quality_effect = { AMOUNT = -3 }
				}
			}
		}
	}

	# Nice
	option = {
		name = fund_inspiration.2030.a
	}
}

# Rival sabotages your sponsee
# by Joe Parkin
fund_inspiration.2040 = {
	type = character_event
	title = fund_inspiration.2040.t
	desc = fund_inspiration.2040.desc
	theme = realm
	override_background = {
		reference = corridor_day
	}
	left_portrait = {
		character = scope:inspiration_owner
		animation = anger
	}
	lower_right_portrait = {
		character = scope:rival
		animation = schadenfreude
	}
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			NOT = { has_character_flag = had_event_fund_inspiration_2040 }
			
		}
		OR = {
			any_relation = {
				type = rival
				fund_inspiration_court_relation_trigger = yes
			}
			scope:inspiration_owner = {
				any_relation = {
					type = rival
					fund_inspiration_court_relation_trigger = yes
				}
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2040
				years = 5
			}
			add_inspiration_cooldown_flag = yes
		}
		if = {
			limit = { intrigue >= average_skill_rating }
			if = {
				limit = {
					any_relation = {
						type = rival
						fund_inspiration_court_relation_trigger = yes
					}
				}
				random_relation = {
					type = rival
					limit = { fund_inspiration_court_relation_trigger = yes }
					save_scope_as = rival
				}
			}
			else = {
				scope:inspiration_owner = {
					random_relation = {
						type = rival
						limit = { fund_inspiration_court_relation_trigger = yes }
						save_scope_as = rival
					}
				}
			}
		}
	}

	option = {
		name = fund_inspiration.2040.a
		trigger = {
			any_relation = {
				type = rival
				fund_inspiration_court_relation_trigger = yes
			}
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = -4 }
		}
	}

	option = {
		name = fund_inspiration.2040.b
		trigger = {
			NOT = {
				any_relation = {
					type = rival
					fund_inspiration_court_relation_trigger = yes
				}
			}
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = -4 }
		}
	}

	option = {
		name = fund_inspiration.2040.c
		trigger = { exists = scope:rival }
		skill = intrigue
		flavor = fund_inspiration.2040.c.flavor
		duel = {
			skill = intrigue
			value = average_skill_rating
			40 = {
				desc = fund_inspiration.2040.c.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				custom_tooltip = fund_inspiration.2040.c.tt
				show_as_tooltip = {
					add_prestige = minor_prestige_gain
					add_intrigue_lifestyle_xp = medium_lifestyle_experience
				}
				trigger_event = {
					id = fund_inspiration.2041
					days = 3
				}
			}
			60 = {
				desc = fund_inspiration.2040.c.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -2
				}
				show_as_tooltip = {
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = -4 }
					}
				}
				trigger_event = {
					id = fund_inspiration.2042
					days = 3
				}
			}
		}
	}
}

fund_inspiration.2041 = {
	type = character_event
	title = fund_inspiration.2040.t
	desc = fund_inspiration.2041.desc
	theme = intrigue
	right_portrait = {
		character = scope:rival
		animation = scheme
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = { fund_inspiration_court_inspiration_owner_trigger = yes }
		exists = scope:rival
		scope:rival = { fund_inspiration_court_relation_trigger = yes }
	}

	immediate = {
		scope:rival = {
			add_character_flag = {
				flag = use_stealth_clothes
				days = 1
			}
		}
		add_intrigue_lifestyle_xp = medium_lifestyle_experience
	}

	option = {
		name = fund_inspiration.2041.a
		add_prestige = minor_prestige_gain
		rightfully_imprison_character_effect = {
			TARGET = scope:rival
			IMPRISONER = root
		}
		stress_impact = {
			calm = medium_stress_impact_gain
			patient = medium_stress_impact_gain
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
			}
		}
	}

	option = {
		name = fund_inspiration.2041.b
		remove_courtier_or_guest = scope:rival
		ai_chance = {
			base = 25
		}
	}

	option = {
		name = fund_inspiration.2041.c
		add_character_modifier = {
			modifier = ep1_fund_inspiration_2040_scheme_modifier
			years = 5
		}
		stress_impact = {
			wrathful = medium_stress_impact_gain
			impatient = medium_stress_impact_gain
			vengeful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
			}
		}
	}
}

fund_inspiration.2042 = {
	type = character_event
	hidden = yes

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = { fund_inspiration_court_inspiration_owner_trigger = yes }
	}

	immediate = {
		send_interface_toast = {
			title = fund_inspiration.2040.c.failure
			left_icon = scope:inspiration_owner
			scope:inspiration_owner = {
				change_artifact_quality_effect = { AMOUNT = -4 }
			}
		}
	}
}

# Skillcheck to improve inspiration quality
# by Joe Parkin
scripted_trigger fund_inspiration_martial_trigger = {
	scope:inspiration = {
		OR = {
			has_inspiration_type = weapon_inspiration
			has_inspiration_type = armor_inspiration
			AND = {
				has_inspiration_type = book_inspiration
				inspiration_owner = {
					trigger_if = {
						limit = { has_variable = book_subject }
						var:book_subject = flag:martial
					}
					trigger_else = { always = no }
				}
			}
		}
	}
}

scripted_trigger fund_inspiration_stewardship_trigger = {
	scope:inspiration = {
		OR = {
			has_inspiration_type = weaver_inspiration
			has_inspiration_type = artisan_inspiration
			has_inspiration_type = smith_inspiration
			AND = {
				has_inspiration_type = book_inspiration
				inspiration_owner = {
					trigger_if = {
						limit = { has_variable = book_subject }
						var:book_subject = flag:stewardship
					}
					trigger_else = { always = no }
				}	
			}
		}
	}
}

scripted_trigger fund_inspiration_diplomacy_trigger = {
	scope:inspiration = {
		has_inspiration_type = book_inspiration
		inspiration_owner = {
			trigger_if = {
				limit = { has_variable = book_subject }
				var:book_subject = flag:diplomacy
			}
			trigger_else = { always = no }
		}
	}
}

scripted_trigger fund_inspiration_intrigue_trigger = {
	scope:inspiration = {
		has_inspiration_type = book_inspiration
		inspiration_owner = {
			trigger_if = {
				limit = { has_variable = book_subject }
				var:book_subject = flag:intrigue
			}
			trigger_else = { always = no }
		}
	}
}

scripted_effect fund_inspiration_skillcheck_duel_effect = {
	duel = {
		skill = $SKILL$
		value = average_skill_rating
		$CHANCE$ = {
			desc = fund_inspiration.2050.success
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
			}
			min = 5
			send_interface_toast = {
				title = fund_inspiration.2050.success
				left_icon = scope:inspiration_owner
				scope:inspiration_owner = {
					change_artifact_quality_effect = { AMOUNT = $AMOUNT$ }
				}
			}
		}
		30 = {
			desc = fund_inspiration.2050.failure
			compare_modifier = {
				value = scope:duel_value
				multiplier = -2
			}
			send_interface_toast = {
				title = fund_inspiration.2050.failure
				left_icon = scope:inspiration_owner
				scope:inspiration_owner = {
					change_artifact_quality_effect = { AMOUNT = -$AMOUNT$ }
				}
			}
		}
		20 = {
			desc = fund_inspiration.2050.nothing
			modifier = {
				factor = 1.5
				scope:inspiration_owner = {
					OR = {
						has_trait = arrogant
						has_trait = stubborn
						opinion = {
							target = root
							value < 0
						}
					}
				}
			}
			modifier = {
				factor = 0.5
				scope:inspiration_owner = {
					OR = {
						has_trait = fickle
						has_trait = humble
						opinion = {
							target = root
							value >= 50
						}
					}
				}
			}
		}
	}
}

fund_inspiration.2050 = {
	type = character_event
	title = fund_inspiration.2050.t
	desc = fund_inspiration.2050.desc
	theme = realm
	override_background = {
		reference = study
	}
	left_portrait = {
		character = scope:inspiration_owner
		animation = worry
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			NOT = { has_character_flag = had_event_fund_inspiration_2050 }
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2050
				years = 5
			}
			add_inspiration_cooldown_flag = yes
		}
	}

	option = { # Skill check based on inspiration type
		name = fund_inspiration.2050.a
		if = { # Martial
			limit = { fund_inspiration_martial_trigger = yes }
			fund_inspiration_skillcheck_duel_effect = { SKILL = martial AMOUNT = 4 CHANCE = 30 }
		}
		else_if = { # Stewardship
			limit = { fund_inspiration_stewardship_trigger = yes }
			fund_inspiration_skillcheck_duel_effect = { SKILL = stewardship AMOUNT = 4 CHANCE = 30 }
		}
		else_if = { # Diplomacy
			limit = { fund_inspiration_diplomacy_trigger = yes }
			fund_inspiration_skillcheck_duel_effect = { SKILL = diplomacy AMOUNT = 4 CHANCE = 30 }
		}
		else_if = { # Intrigue
			limit = { fund_inspiration_intrigue_trigger = yes }
			fund_inspiration_skillcheck_duel_effect = { SKILL = intrigue AMOUNT = 4 CHANCE = 30 }
		}
		else = { # Learning
			fund_inspiration_skillcheck_duel_effect = { SKILL = learning AMOUNT = 4 CHANCE = 30 }
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = contempt_opinion
			opinion = -10
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
				ai_rationality = -1
			}
		}
	}

	option = { # Education fallback
		name = fund_inspiration.2050.b
		trigger = {
			OR = {
				AND = {
					fund_inspiration_diplomacy_trigger = no
					has_trait = education_diplomacy
				}
				AND = {
					fund_inspiration_martial_trigger = no
					has_trait = education_martial
				}
				AND = {
					fund_inspiration_stewardship_trigger = no
					has_trait = education_stewardship
				}
				AND = {
					fund_inspiration_intrigue_trigger = no
					has_trait = education_intrigue
				}
			}
			NOT = { 
				scope:inspiration = {
					has_inspiration_type = research_inspiration
				}
			}
		}
		trait = education_diplomacy_1
		trait = education_diplomacy_2
		trait = education_diplomacy_3
		trait = education_diplomacy_4
		trait = education_diplomacy_5
		trait = education_martial_1
		trait = education_martial_2
		trait = education_martial_3
		trait = education_martial_4
		trait = education_martial_5
		trait = education_stewardship_1
		trait = education_stewardship_2
		trait = education_stewardship_3
		trait = education_stewardship_4
		trait = education_stewardship_5
		trait = education_intrigue_1
		trait = education_intrigue_2
		trait = education_intrigue_3
		trait = education_intrigue_4
		trait = education_intrigue_5
		trait = education_learning_1
		trait = education_learning_2
		trait = education_learning_3
		trait = education_learning_4
		trait = education_learning_5
		if = { # Martial
			limit = {
				fund_inspiration_martial_trigger = no
				has_trait = education_martial
			}
			fund_inspiration_skillcheck_duel_effect = { SKILL = martial AMOUNT = 2 CHANCE = 5 }
		}
		else_if = { # Stewardship
			limit = {
				fund_inspiration_stewardship_trigger = no
				has_trait = education_stewardship
			}
			fund_inspiration_skillcheck_duel_effect = { SKILL = stewardship AMOUNT = 2 CHANCE = 5 }
		}
		else_if = { # Diplomacy
			limit = {
				fund_inspiration_diplomacy_trigger = no
				has_trait = education_diplomacy
			}
			fund_inspiration_skillcheck_duel_effect = { SKILL = diplomacy AMOUNT = 2 CHANCE = 5 }
		}
		else_if = { # Intrigue
			limit = {
				fund_inspiration_intrigue_trigger = no
				has_trait = education_intrigue
			}
			fund_inspiration_skillcheck_duel_effect = { SKILL = intrigue AMOUNT = 2 CHANCE = 5 }
		}
		else = { # Learning
			fund_inspiration_skillcheck_duel_effect = { SKILL = learning AMOUNT = 2 CHANCE = 5 }
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = contempt_opinion
			opinion = -10
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_rationality = -0.5
			}
		}
	}

	option = { # Highest skill fallback (if inspiration and education match)
		name = fund_inspiration.2050.c
		trigger = {
			NOR = {
				AND = {
					fund_inspiration_diplomacy_trigger = no
					has_trait = education_diplomacy
				}
				AND = {
					fund_inspiration_martial_trigger = no
					has_trait = education_martial
				}
				AND = {
					fund_inspiration_stewardship_trigger = no
					has_trait = education_stewardship
				}
				AND = {
					fund_inspiration_intrigue_trigger = no
					has_trait = education_intrigue
				}
			}
		}
		if = { # Martial
			limit = {
				fund_inspiration_martial_trigger = no
				NOT = { has_trait = education_martial }
				highest_skill = martial
			}
			fund_inspiration_skillcheck_duel_effect = { SKILL = martial AMOUNT = 2 CHANCE = 5 }
		}
		else_if = { # Stewardship
			limit = {
				fund_inspiration_stewardship_trigger = no
				NOT = { has_trait = education_stewardship }
				highest_skill = stewardship
			}
			fund_inspiration_skillcheck_duel_effect = { SKILL = stewardship AMOUNT = 2 CHANCE = 5 }
		}
		else_if = { # Diplomacy
			limit = {
				fund_inspiration_diplomacy_trigger = no
				NOT = { has_trait = education_diplomacy }
				highest_skill = diplomacy
			}
			fund_inspiration_skillcheck_duel_effect = { SKILL = diplomacy AMOUNT = 2 CHANCE = 5 }
		}
		else_if = { # Intrigue
			limit = {
				fund_inspiration_intrigue_trigger = no
				NOT = { has_trait = education_intrigue }
				highest_skill = intrigue
			}
			fund_inspiration_skillcheck_duel_effect = { SKILL = intrigue AMOUNT = 2 CHANCE = 5 }
		}
		else = { # Learning
			fund_inspiration_skillcheck_duel_effect = { SKILL = learning AMOUNT = 2  CHANCE = 10 } # more for learning
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = contempt_opinion
			opinion = -10
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_rationality = -0.5
			}
		}
	}

	option = { # Prowess bonus option for equipment
		name = fund_inspiration.2050.d
		trigger = {
			scope:inspiration = {
				OR = {
					has_inspiration_type = weapon_inspiration
					has_inspiration_type = armor_inspiration
				}
			}
		}
		skill = prowess
		fund_inspiration_skillcheck_duel_effect = { SKILL = prowess AMOUNT = 4 CHANCE = 10 }
		stress_impact = {
			humble = minor_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_rationality = -0.5
			}
		}
	}

	option = { # Don't get involved
		name = fund_inspiration.2050.e
		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = -1
				ai_rationality = 1
			}
		}
	}
}

# Fame donation
# by Joe Parkin
fund_inspiration.2060 = {
	type = character_event
	title = fund_inspiration.2060.t
	desc = {
		random_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						piety_level >= high_piety_level
						has_trait = saoshyant
						has_trait = savior
						has_trait = saint
					}
				}
				desc =  fund_inspiration.2060.desc.religious
			}
			triggered_desc = {
				trigger = { prestige_level >= high_prestige_level }
				desc =  fund_inspiration.2060.desc.fame
			}
			triggered_desc = {
				trigger = { court_grandeur_current_level >= 8 }
				desc =  fund_inspiration.2060.desc.court
			}
		}
		desc = fund_inspiration.2060.desc
		random_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						piety_level >= high_piety_level
				   		has_trait = saoshyant
						has_trait = savior
						has_trait = saint
					}
				}
				desc =  fund_inspiration.2060.desc.brotherhood
			}
			triggered_desc = {
				trigger = {
					OR = {
						piety_level >= high_piety_level
				   		has_trait = saoshyant
						has_trait = savior
						has_trait = saint
					}
				}
				desc =  fund_inspiration.2060.desc.abbey
			}
			triggered_desc = {
				trigger = {
					OR = {
						prestige_level >= high_prestige_level
						court_grandeur_current_level >= 8
					}
				}
				desc =  fund_inspiration.2060.desc.mercenary
			}
			triggered_desc = {
				trigger = {
					OR = {
						prestige_level >= high_prestige_level
						court_grandeur_current_level >= 8
					}
				}
				desc =  fund_inspiration.2060.desc.guild
			}
		}
		random_valid = {
			triggered_desc = {
				trigger = { piety_level >= high_piety_level }
				desc =  fund_inspiration.2060.piety
			}
			triggered_desc = {
				trigger = { has_trait = saoshyant }
				desc =  fund_inspiration.2060.saoshyant
			}
			triggered_desc = {
				trigger = { has_trait = savior }
				desc =  fund_inspiration.2060.savior
			}
			triggered_desc = {
				trigger = { has_trait = saint }
				desc =  fund_inspiration.2060.saint
			}
			triggered_desc = {
				trigger = { prestige_level >= high_prestige_level }
				desc =  fund_inspiration.2060.prestige
			}
			triggered_desc = {
				trigger = { court_grandeur_current_level >= 8 }
				desc =  fund_inspiration.2060.grandeur
			}
		}
		desc = fund_inspiration.2060.desc_outro
	}
	theme = realm
	left_portrait = {
		character = scope:donator
		animation = admiration
	}
	right_portrait = {
		character = scope:inspiration_owner
		animation = happiness
	}
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			#NOT = { has_character_flag = had_event_fund_inspiration_2060 }
		}
		OR = {
			piety_level = max_piety_level
			has_trait = saoshyant
			has_trait = savior
			has_trait = saint
			prestige_level = max_prestige_level
			court_grandeur_current_level >= 8
		}
		any_held_county = {
			any_county_province = { has_holding = yes }
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			#add_character_flag = {
			#	flag = had_event_fund_inspiration_2060
			#	years = 5
			#}
			add_inspiration_cooldown_flag = yes
		}
		# Generate donating character
		random_list = {
			2 = { # Religious
				trigger = {
					OR = {
						piety_level = max_piety_level
						has_trait = saoshyant
						has_trait = savior
						has_trait = saint
					}
				}
				create_character = {
					template = monk_character_template
					dynasty = none
					location = root.capital_province
					save_scope_as = donator
				}
			}
			2 = { # Secular
				trigger = {
					OR = {
						prestige_level = max_prestige_level
						court_grandeur_current_level >= 8
					}
				}
				create_character = {
					template = new_warrior_character
					gender_female_chance = root_soldier_female_chance
					culture = root.culture
					faith = root.faith
					dynasty = none
					location = root.capital_province
					save_scope_as = donator
				}
			}
		}
		hidden_effect = {
			scope:donator = { add_gold = root.minor_gold_value }
		}
		# Find county origin
		random_held_county = {
			limit = {
				NOT = { this = root.capital_county }
				any_county_province = { has_holding = yes }
			}
			alternative_limit = {
				any_county_province = { has_holding = yes }
			}
			random_county_province = {
				limit = { has_holding = yes }
				barony = { save_scope_as = barony_scope }
			}
		}
	}

	option = { # I am honored
		name = fund_inspiration.2060.a
		scope:donator = {
			pay_short_term_gold = {
				target = root
				gold = root.tiny_gold_value
			}
		}
		scope:inspiration = { invest_gold = root.tiny_gold_value }
		scope:barony_scope.county = {
			add_county_modifier = {
				modifier = ep1_fund_inspiration_2070_accept_modifier
				years = 5
			}
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = 2 }
		}
		stress_impact = {
			generous = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.5
				ai_boldness = 1
			}
		}
	}

	option = { # Refuse gift
		name = {
			trigger = {
				OR = {
					piety_level = max_piety_level
					has_trait = saoshyant
					has_trait = savior
					has_trait = saint
				}
			}
			text = fund_inspiration.2060.b.religious
		}
		name = {
			trigger = {
				OR = {
					prestige_level = max_prestige_level
					court_grandeur_current_level >= 8
				}
			}
			text = fund_inspiration.2060.b.prestige
		}
		scope:barony_scope.county = {
			add_county_modifier = {
				modifier = ep1_fund_inspiration_2070_refuse_modifier
				years = 5
			}
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = annoyed_opinion
			opinion = -10
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -1
			}
		}
	}

	option = { # Mock gift
		name = fund_inspiration.2060.c
		if = {
			limit = {
				scope:donator = { has_trait = devoted }
			}
			add_piety = medium_piety_loss
		}
		else = {
			add_prestige = medium_prestige_loss	
		}
		scope:donator = {
			pay_short_term_gold = {
				target = root
				gold = root.tiny_gold_value
			}
		}
		scope:inspiration = { invest_gold = root.tiny_gold_value }
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = 2 }
		}
		scope:barony_scope.county = {
			add_county_modifier = {
				modifier = ep1_fund_inspiration_2070_mock_modifier
				years = 5
			}
		}
		stress_impact = {
			humble = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.5
				ai_compassion = -1
			}
		}
	}
}

# Flawed artisan
# by Joe Parkin
scripted_trigger has_artisan_incapacity_trait = {
	OR = {
		has_trait = lunatic
		has_trait = possessed
		has_trait = depressed
		has_trait = drunkard
		has_trait = hashishiyah
		has_trait = reclusive
		has_trait = rakish
		has_trait = profligate
		has_trait = improvident
		has_trait = comfort_eater
		has_trait = irritable
		has_trait = wounded
		has_trait = pregnant
		has_treatable_disease_trigger = yes
	}
}

fund_inspiration.2070 = {
	type = character_event
	title = fund_inspiration.2070.t
	desc = {
		desc = fund_inspiration.2070.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = {
						OR = {
							has_trait = profligate
							has_trait = improvident
							has_trait = depressed
							has_trait = drunkard
							has_trait = hashishiyah
							has_trait = rakish
							has_trait = comfort_eater
							has_trait = wounded
							has_trait = pregnant
							has_treatable_disease_trigger = yes
						}
					}
				}
				desc = fund_inspiration.2070.desc.stalled
			}
			triggered_desc = {
			   trigger = {
					scope:inspiration_owner = {
						OR = {
							has_trait = lunatic
							has_trait = possessed
							has_trait = reclusive
							has_trait = irritable
						}
					}
				}
				desc = fund_inspiration.2070.desc.wasted
			}	
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = profligate }
				}
				desc = fund_inspiration.2070.desc.profligate
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = improvident }
				}
				desc = fund_inspiration.2070.desc.improvident
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = depressed }
				}
				desc = fund_inspiration.2070.desc.depressed
			}
			triggered_desc = {
		   		trigger = {
					scope:inspiration_owner = { has_trait = drunkard }
				}
				desc = fund_inspiration.2070.desc.drunkard
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = hashishiyah }
				}
				desc = fund_inspiration.2070.desc.hashishiyah
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = rakish }
				}
				desc = fund_inspiration.2070.desc.rakish
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = comfort_eater }
				}
				desc = fund_inspiration.2070.desc.comfort_eater
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = lunatic }
				}
				desc = fund_inspiration.2070.desc.lunatic
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = possessed }
				}
				desc = fund_inspiration.2070.desc.possessed
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = reclusive }
				}
				desc = fund_inspiration.2070.desc.reclusive
			}		
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = irritable }
				}
				desc = fund_inspiration.2070.desc.irritable
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = wounded }
				}
				desc = fund_inspiration.2070.desc.wounded
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_trait = pregnant }
				}
				desc = fund_inspiration.2070.desc.pregnant
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { has_treatable_disease_trigger = yes }
				}
				desc = fund_inspiration.2070.desc.sick
			}			
		}
		desc = fund_inspiration.2070.desc_outro
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		triggered_animation = {
			trigger = { has_trait = pregnant }
			animation = pregnant
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = lunatic
					has_trait = possessed
				}
			}
			animation = lunatic
		}
		triggered_animation = {
			trigger = { has_trait = depressed }
			animation = boredom
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = drunkard
					has_trait = hashishiyah
					has_trait = rakish
				}
			}
			animation = toast
		}
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = profligate
					has_trait = improvident
				}
			}
			animation = boredom
		}
		triggered_animation = {
			trigger = { has_trait = irritable }
			animation = anger
		}
		triggered_animation = {
			trigger = { has_treatable_disease_trigger = yes }
			animation = sick
		}
	}
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			NOT = { has_character_flag = had_event_fund_inspiration_2070 }
			has_artisan_incapacity_trait = yes
			inspiration.inspiration_progress >= 2
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2070
				years = 5
			}
			add_inspiration_cooldown_flag = yes
			inspiration = { change_inspiration_progress = -2 }
		}
	}

	option = { # Pull yourself together
		name = fund_inspiration.2070.a
		scope:inspiration = {
			if = {
				limit = {
					inspiration_owner = {
						OR = {
							has_trait = profligate
							has_trait = improvident
						}
					}
				}
				invest_gold = root.medium_gold_value
				root = {
					stress_impact = { greedy = medium_stress_impact_gain }
				}
			}
			else = {
				invest_gold = root.minor_gold_value
				root = {
					stress_impact = { greedy = minor_stress_impact_gain }
				}
			}
			change_inspiration_progress = 1
		}
		stress_impact = {
			vengeful = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			wrathful = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_greed = -0.5
				ai_compassion = 0.5
			}
		}
	}

	option = { # I understand
		name = fund_inspiration.2070.b
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = forgiven_opinion
			opinion = 10
		}
		stress_impact = {
			vengeful = medium_stress_impact_gain
			callous = medium_stress_impact_gain
			impatient = medium_stress_impact_gain
			arbitrary = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_greed = -1
				ai_compassion = 1
			}
		}
	}

	option = { # Unacceptable
		name = fund_inspiration.2070.c
		scope:inspiration_owner = {
			inspiration = { change_inspiration_progress = 2 }
			stress_impact = {
				base = massive_stress_impact_gain
				craven = medium_stress_impact_gain
				lazy = medium_stress_impact_gain
			}
			change_artifact_quality_effect = { AMOUNT = -4 }
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			patient = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 1
				ai_greed = 1
				ai_compassion = -1
			}
		}
	}

	option = { # Get out
		name = fund_inspiration.2070.d
		trigger = {
			scope:inspiration_owner = { is_courtier = yes }
		}
		send_interface_toast = {
			title = fund_inspiration.2100.c.leave
			left_icon = scope:inspiration_owner
			add_prestige = minor_prestige_gain
			end_inspiration_sponsorship = scope:inspiration
			remove_courtier_or_guest = scope:inspiration_owner
			if = {
				limit = {
					scope:inspiration_owner = {
						NOR = {
							has_trait = profligate
							has_trait = improvident
						}
					}
				}
				custom_tooltip = fund_inspiration_quarter_refund_tt
				add_gold = {
					value = scope:inspiration.inspiration_gold_invested
					divide = 4
				}
			}
		}
		stress_impact = {
			forgiving = major_stress_impact_gain
			patient = major_stress_impact_gain
			greedy = major_stress_impact_gain
			compassionate = major_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 2
				ai_greed = -1
				ai_compassion = -1
			}
		}
	}
}

# Antiquarian meddles with inspiration
# by Joe Parkin
scripted_trigger fi_2080_antiquarian_trigger = {
	is_available_ai_adult = yes
	NOR = {
		this = scope:inspiration_owner
		has_any_good_relationship_with_character_trigger = { CHARACTER = scope:inspiration_owner }
	}
}

fund_inspiration.2080 = {
	type = character_event
	title = fund_inspiration.2080.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:rival = { has_court_position = antiquarian_court_position }
				}
				desc = fund_inspiration.2080.antiquarian
			}
			triggered_desc = {
				trigger = {
					scope:rival = { has_court_position = court_artificer_court_position }
				}
				desc = fund_inspiration.2080.artificer
			}
		}
		desc = fund_inspiration.2080.desc
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = dismissal
	}
	right_portrait = {
		character = scope:antiquarian
		animation = disapproval
	}
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			NOR = {
				has_character_flag = had_event_fund_inspiration_2080
				has_variable = banner_commission
			}
		}
		OR = {
			any_court_position_holder = {
				type = antiquarian_court_position
				fi_2080_antiquarian_trigger = yes
			}
			any_court_position_holder = {
				type = court_artificer_court_position
				fi_2080_antiquarian_trigger = yes
			}	
		}
	}

	immediate = {
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_2080
				years = 5
			}
			add_inspiration_cooldown_flag = yes
		}
		if = {
			limit = {
				any_court_position_holder = {
					type = antiquarian_court_position
					fi_2080_antiquarian_trigger = yes
				}
			}
			random_court_position_holder = {
				type = antiquarian_court_position
				limit = { fi_2080_antiquarian_trigger = yes }
				save_scope_as = antiquarian
				progress_towards_rival_effect = {
					REASON = rival_dispute_inspiration
					CHARACTER = scope:inspiration_owner
					OPINION = 0
				}
			}
		}
		if = {
			limit = {
				any_court_position_holder = {
					type = court_artificer_court_position
					fi_2080_antiquarian_trigger = yes
				}
			}
			random_court_position_holder = {
				type = court_artificer_court_position
				limit = { fi_2080_antiquarian_trigger = yes }
				save_scope_as = artificer
			}
		}
		random_list = {
			2 = {
				trigger = { exists = scope:antiquarian }
				modifier = {
					factor = 10
					scope:antiquarian = {
						OR = {
							has_trait = diligent
							has_trait = arrogant
							has_relation_rival = scope:inspiration_owner
						}
					}
				}
				scope:antiquarian = { save_scope_as = rival }
			}
			2 = {
				trigger = { exists = scope:artificer }
				modifier = {
					factor = 10
					scope:artificer = {
						OR = {
							has_trait = diligent
							has_trait = arrogant
							has_relation_rival = scope:inspiration_owner
						}
					}
				}
				scope:artificer = { save_scope_as = rival }
			}
		}
	}

	option = { # Side with position holder
		name = fund_inspiration.2080.a
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = disappointed_opinion
			opinion = -10
		}
		reverse_add_opinion = {
			target = scope:rival
			modifier = respect_opinion
			opinion = 5
		}
		random_list = {
			5 = {
				modifier = { factor = scope:rival.aptitude:antiquarian_court_position }
				send_interface_toast = {
					title = fund_inspiration.2080.success
					left_icon = scope:rival
					right_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = 4 }
					}
				}
			}
			10 = {
				send_interface_toast = {
					title = fund_inspiration.2080.failure
					left_icon = scope:rival
					right_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = -4 }
					}
				}
			}
		}
		stress_impact = {
			generous = minor_stress_impact_gain
			patient = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.5
				ai_compassion = -0.5
			}
		}
	}

	option = { # Side with sponsee
		name = fund_inspiration.2080.b
		reverse_add_opinion = {
			target = scope:rival
			modifier = disappointed_opinion
			opinion = -10
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = respect_opinion
			opinion = 5
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -1
				ai_compassion = 1
			}
		}
	}

	option = { # Replace with sponsee
		name = fund_inspiration.2080.c
		reverse_add_opinion = {
			target = scope:rival
			modifier = angry_opinion
			opinion = -20
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = grateful_opinion
			opinion = 10
		}
		scope:rival = {
			progress_towards_rival_effect = {
				REASON = rival_dispute_inspiration
				CHARACTER = scope:inspiration_owner
				OPINION = 0
			}
		}
		if = {
			limit = {
				scope:rival = { has_court_position = court_artificer_court_position }
			}
			replace_court_position = {
				recipient = scope:inspiration_owner
				holder = scope:rival
				court_position = court_artificer_court_position
			}
		}
		else = {
			replace_court_position = {
				recipient = scope:inspiration_owner
				holder = scope:rival
				court_position = antiquarian_court_position
			}
		}
		random = {
			chance = 50
			scope:inspiration_owner = {
				change_artifact_quality_effect = { AMOUNT = 2 }
			}
		}
		stress_impact = {
			calm = medium_stress_impact_gain
			just = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 1
			}
		}
	}
}

# Spouse meddles with inspiration
# by Joe Parkin
fund_inspiration.2090 = {
	type = character_event
	title = fund_inspiration.2090.t
	desc = fund_inspiration.2090.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = stress
	}
	right_portrait = {
		character = scope:event_spouse
		animation = happiness
	}
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		exists = primary_spouse
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			NOR = {
				has_character_flag = had_event_fund_inspiration_2090
				has_variable = banner_commission
			}
		}
		scope:inspiration = {
			OR = {
				has_inspiration_type = weaver_inspiration
				has_inspiration_type = artisan_inspiration
				has_inspiration_type = smith_inspiration
				has_inspiration_type = research_inspiration
				trigger_if = {
					limit = {
						root.primary_spouse = {
							can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
						}
					}
					OR = {
						has_inspiration_type = weapon_inspiration
						has_inspiration_type = armor_inspiration
					}
				}
			}
		}
		is_married = yes
		primary_spouse = {
			is_available_ai_adult = yes
			is_landed = no
			is_in_the_same_court_as_or_guest = root
			NOT = { this = scope:inspiration_owner }
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = {
				OR = {
					has_trait = diligent
					has_trait = arrogant
				}
			}
		}
		modifier = {
			add = -1
			primary_spouse = {
				OR = {
					has_trait = humble
					has_trait = shy
					has_trait = lazy
				}
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_2090
				years = 5
			}
			add_inspiration_cooldown_flag = yes
		}
		primary_spouse = { save_scope_as = event_spouse }
	}

	option = {
		name = fund_inspiration.2090.a
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = angry_opinion
			opinion = -10
		}
		reverse_add_opinion = {
			target = scope:event_spouse
			modifier = pleased_opinion
			opinion = 5
		}
		random_list = {
			4 = {
				modifier = { factor = scope:event_spouse.aptitude:antiquarian_court_position }
				send_interface_toast = {
					title = fund_inspiration.2090.success
					left_icon = scope:event_spouse
					right_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = 4 }
					}
				}
			}
			10 = {
				send_interface_toast = {
					title = fund_inspiration.2090.failure
					left_icon = scope:event_spouse
					right_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = -4 }
					}
				}
			}
		}
		stress_impact = {
			generous = minor_stress_impact_gain
			patient = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -1
				ai_compassion = 1
			}
		}
	}

	option = {
		name = fund_inspiration.2090.b
		reverse_add_opinion = {
			target = scope:event_spouse
			modifier = disappointed_opinion
			opinion = -10
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = grateful_opinion
			opinion = 5
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			callous = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.5
				ai_compassion = -0.5
			}
		}
	}
}

# Sponsee jealous of another sponsee
# by Joe Parkin
fund_inspiration.2100 = {
	type = character_event
	title = fund_inspiration.2100.t
	desc = {
		desc = fund_inspiration.2100.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:other_inspiration_owner.inspiration.inspiration_gold_invested > scope:inspiration.inspiration_gold_invested }
				desc = fund_inspiration.2100.desc.funds
			}
			triggered_desc = {
				trigger = {
					scope:other_inspiration_owner = { has_relation_rival = scope:inspiration_owner }
				}
				desc = fund_inspiration.2100.desc.rival
			}
			desc = fund_inspiration.2100.desc.fallback
		}
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = disapproval
	}
	right_portrait = {
		character = scope:other_inspiration_owner
		animation = admiration
	}
	override_background = {
		reference = feast
	}
	cooldown = { years = 2 }

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			NOR = {
				has_character_flag = had_event_fund_inspiration_2100
				has_variable = banner_commission
			}
			OR = {
				NOR = {
					has_trait = humble
					has_trait = shy
					has_trait = lazy
				}
				any_relation = {
					type = rival
					exists = inspiration.inspiration_sponsor
					inspiration.inspiration_sponsor = root
				}
			}
		}
		any_sponsored_inspiration = {
			NOT = { inspiration_owner = scope:inspiration_owner }
			inspiration_owner = { fund_inspiration_court_inspiration_owner_trigger = yes }
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			scope:inspiration_owner = {
				OR = {
					has_trait = diligent
					has_trait = arrogant
				}
			}
		}
		modifier = {
			factor = 2
			any_sponsored_inspiration = {
				NOT = { inspiration_owner = scope:inspiration_owner }
				inspiration_owner = { fund_inspiration_court_inspiration_owner_trigger = yes }
				inspiration_gold_invested > scope:inspiration.inspiration_gold_invested
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_2100
				years = 5
			}
			add_inspiration_cooldown_flag = yes
		}
		random_sponsored_inspiration = {
			limit = {
				NOT = { inspiration_owner = scope:inspiration_owner }
				inspiration_owner = { fund_inspiration_court_inspiration_owner_trigger = yes }
			}
			weight = {
				base = 1
				modifier = {
					factor = 2
					inspiration_gold_invested > scope:inspiration.inspiration_gold_invested
				}
				modifier = {
					factor = 4
					inspiration_owner = { has_relation_rival = scope:inspiration_owner }
				}
			}
			inspiration_owner = { save_scope_as = other_inspiration_owner }
		}
	}

	option = { # Praise work
		name = fund_inspiration.2100.a
		add_prestige = minor_prestige_loss
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = pleased_opinion
			opinion = 5
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
			callous = medium_stress_impact_gain	
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = 1
			}
		}
	}

	option = { # Match funding
		name = fund_inspiration.2100.b
		trigger = { scope:inspiration.inspiration_gold_invested < scope:other_inspiration_owner.inspiration.inspiration_gold_invested }
		if = {
			limit = { ep1_fund_inspiration_2100_rival_difference < 50 }
			scope:inspiration_owner = {
				change_artifact_quality_effect = { AMOUNT = 2 }
			}
		}
		else = {
			scope:inspiration_owner = {
				change_artifact_quality_effect = { AMOUNT = 4 }
			}
		}
		scope:inspiration = { invest_gold = ep1_fund_inspiration_2100_rival_difference }
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = pleased_opinion
			opinion = 10
		}
		reverse_add_opinion = {
			target = scope:other_inspiration_owner
			modifier = annoyed_opinion
			opinion = -10
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
			arbitrary = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -1
				ai_honor = 1
			}
		}
	}

	option = { # Attempt to settle dispute
		name = fund_inspiration.2100.c
		duel = {
			skill = diplomacy
			target = scope:inspiration_owner
			10 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 4
				}
				min = 5
				send_interface_toast = {
					title = fund_inspiration.2100.success
					left_icon = scope:inspiration_owner
					right_icon = scope:other_inspiration_owner
					scope:inspiration_owner = {
						add_opinion = {
							target = root
							modifier = respect_opinion
							opinion = 5
						}
						change_artifact_quality_effect = { AMOUNT = 2 }
					}
				}
			}
			20 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 2
				}
				min = 5
				send_interface_toast = {
					title = fund_inspiration.2100.failure
					left_icon = scope:inspiration_owner
					right_icon = scope:other_inspiration_owner
					scope:inspiration_owner = {
						add_opinion = {
							target = root
							modifier = insulted_opinion
							opinion = -10
						}
						progress_towards_rival_effect = {
							REASON = rival_dispute_inspiration
							CHARACTER = scope:other_inspiration_owner
							OPINION = 0
						}
						change_artifact_quality_effect = { AMOUNT = -4 }
					}
				}
			}
		}
		stress_impact = {
			lazy = medium_stress_impact_gain
			arbitrary = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_energy = 1
				ai_honor = 1
			}
		}
	}

	option = { # Berate
		name = fund_inspiration.2100.d
		add_prestige = minor_prestige_gain
		reverse_add_opinion = {
			target = scope:other_inspiration_owner
			modifier = grateful_opinion
			opinion = 5
		}
		random_list = {
			50 = {
				send_interface_toast = {
					title = fund_inspiration.2100.c.leave
					left_icon = scope:inspiration_owner
					end_inspiration_sponsorship = scope:inspiration
					if = {
						limit = {
							scope:inspiration_owner = { is_courtier = yes }
						}
						remove_courtier_or_guest = scope:inspiration_owner
					}
					custom_tooltip = fund_inspiration_half_refund_tt
					add_gold = {
						value = scope:inspiration.inspiration_gold_invested
						divide = 2
					}
				}
			}
			50 = {
				send_interface_toast = {
					title = fund_inspiration.2100.c.worse
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = -4 }
					}
				}
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			generous = minor_stress_impact_gain
			patient = minor_stress_impact_gain
			calm = minor_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = -1
			}
		}
	}
}

# Vassal invests in inspiration
# by Joe Parkin
scripted_trigger fi_2110_generous_vassal_trigger = {
	is_available_ai_adult = yes
	gold >= medium_gold_value
	has_any_bad_relationship_with_root_trigger = no
	NOR = {
		has_trait = greedy
		this = scope:inspiration_owner
	}
	OR = {
		gold >= major_gold_value
		has_trait = scholar
	 	has_trait = theologian
		has_trait = diligent
		has_trait = profligate
	 	has_trait = generous
		has_trait = improvident
		has_trait = diligent
		has_any_good_relationship_with_root_trigger = yes
	}
}

fund_inspiration.2110 = {
	type = character_event
	title = fund_inspiration.2110.t
	desc = {
		desc = fund_inspiration.2110.desc
		random_valid = {
			triggered_desc = {
				trigger = {
					scope:inspiration = { has_inspiration_type = research_inspiration }
				}
				desc = fund_inspiration.2110.desc.part.2.research
			}
			triggered_desc = {
				desc = fund_inspiration.2110.desc.part.2
			}
		}
		random_valid = {
			triggered_desc = {
				trigger = {
					scope:generous_vassal = {
						OR = {
							has_trait = profligate
						 	has_trait = generous
							has_trait = improvident
						}
					}
				}
				desc = fund_inspiration.2110.desc.generous
			}
			triggered_desc = {
				trigger = {
					scope:generous_vassal = {
						NOT = {
							scope:inspiration = { has_inspiration_type = research_inspiration }
						}
						OR = {
							has_trait = scholar
					 		has_trait = theologian
					 		has_trait = diligent
					 	}
					 }
				}
				desc = fund_inspiration.2110.desc.dweeb
			}
			triggered_desc = {
				trigger = {
					scope:generous_vassal = {
						scope:inspiration = { has_inspiration_type = research_inspiration }
						OR = {
							has_trait = scholar
					 		has_trait = theologian
					 		has_trait = diligent
					 	}
					 }
				}
				desc = fund_inspiration.2110.desc.dweeb.research
			}
			triggered_desc = {
				trigger = {
					scope:generous_vassal = { has_any_good_relationship_with_root_trigger = yes }
				}
				desc = fund_inspiration.2110.desc.friend
			}
			triggered_desc = {
				trigger = {
					scope:generous_vassal = {
						NOR = {
							has_trait = profligate
						 	has_trait = generous
							has_trait = improvident
							has_trait = scholar
					 		has_trait = theologian
					 		has_trait = diligent
					 		has_any_good_relationship_with_root_trigger = yes
						}
					}
				}
				desc = fund_inspiration.2110.desc.rich
			}
		}
	}
	theme = realm
	left_portrait = {
		character = scope:generous_vassal
		animation = admiration
	}
	lower_right_portrait = scope:inspiration_owner
	cooldown = { years = 2 }

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			NOR = {
				has_character_flag = had_event_fund_inspiration_2100
				has_variable = banner_commission
			}
		}
		any_vassal_or_below = { fi_2110_generous_vassal_trigger = yes }
	}

	immediate = {
		scope:inspiration_owner = {
		 	add_character_flag = {
				flag = had_event_fund_inspiration_2100
				years = 5
			}
			add_inspiration_cooldown_flag = yes
		}
		random_vassal_or_below = {
			limit = { fi_2110_generous_vassal_trigger = yes }
			save_scope_as = generous_vassal
		}
	}

	option = {
		name = fund_inspiration.2110.a
		scope:generous_vassal = {
			hidden_effect = {
				pay_short_term_gold = {
					target = root
					gold = minor_gold_value
				}
			}
			show_as_tooltip = {
				pay_short_term_gold = {
					target = scope:inspiration_owner
					gold = minor_gold_value
				}
			}
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = 2 }
			hidden_effect = {
				inspiration = { invest_gold = scope:generous_vassal.minor_gold_value }
			}
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			arbitrary = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -0.5
				ai_honor = -0.5
			}
		}
	}

	option = {
		name = fund_inspiration.2110.b
		flavor = fund_inspiration.2110.b.flavor
		scope:generous_vassal = {
			pay_short_term_gold = {
				target = root
				gold = minor_gold_value
			}
		}
		stress_impact = {
			honest = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			just = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -1
				ai_honor = -1
				ai_compassion = -1
			}
		}
	}

	option = {
		name = fund_inspiration.2110.c
		reverse_add_opinion = {
			target = scope:generous_vassal
			modifier = respect_opinion
			opinion = 10
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = disappointed_opinion
			opinion = -5
		}
		stress_impact = {
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -1
			}
		}
	}
}

# Sponsee romance
# by Joe Parkin
scripted_trigger fi_2120_homosexuality_not_accepted_trigger = {
	sex_same_as = scope:inspiration_owner
	NOT = {
		faith = { has_doctrine = doctrine_homosexuality_accepted }
	}
}

fund_inspiration.2120 = {
	type = character_event
	title = fund_inspiration.2120.t
	desc = {
		desc = fund_inspiration.2120.desc
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = fund_inspiration_2070_instigator }
				desc = fund_inspiration.2120.desc.me
			}
			desc = fund_inspiration.2120.desc.them
		}
		first_valid = {
			# THEY react
			triggered_desc = {
				trigger = {
					has_character_flag = fund_inspiration_2070_instigator
					scope:inspiration_owner = { has_trait = lustful }
				}
				desc = fund_inspiration.2120.desc.them_into_alot
			}
			triggered_desc = {
				trigger = { has_character_flag = fund_inspiration_2070_instigator }
				desc = fund_inspiration.2120.desc.them_into
			}
			# ROOT reacts
			triggered_desc = {
				trigger = {
					NOT = { is_attracted_to_gender_of = scope:inspiration_owner }
				}
				desc = fund_inspiration.2120.desc.me_unattracted
			}
  			triggered_desc = {
				trigger = {
					has_trait = zealous
					sex_same_as = scope:inspiration_owner
					NOT = {
						faith = { has_doctrine = doctrine_homosexuality_accepted }
					}
				}
				desc = fund_inspiration.2120.desc.me_zealous_homosexuality
			}
			triggered_desc = {
				trigger = {
					has_trait = zealous
					OR = {
						would_be_sinful_adulterer_trigger = yes
						scope:inspiration_owner = { would_be_sinful_adulterer_trigger = yes }
					}
				}
				desc = fund_inspiration.2120.desc.me_zealous_adultery
			}
			triggered_desc = {
				trigger = { has_trait = chaste }
				desc = fund_inspiration.2120.desc.me_chaste
			}
			triggered_desc = {
				trigger = { has_trait = lustful }
				desc = fund_inspiration.2120.desc.me_into_alot
			}
			triggered_desc = {
				trigger = { is_attracted_to_gender_of = scope:inspiration_owner }
				desc = fund_inspiration.2120.desc.me_into
			}
		}
	}
	theme = realm
	override_background = {
		reference = sitting_room
	}
	left_portrait = {
		character = root
		triggered_animation = {
			trigger = {
				NOT = { has_trait = chaste }
				is_attracted_to_gender_of = scope:inspiration_owner
			}
			animation = flirtation_left
		}
		triggered_animation = {
			trigger = {
				NOT = { is_attracted_to_gender_of = scope:inspiration_owner }
			}
			animation = disgust
		}
		triggered_animation = {
			trigger = { has_trait = chaste }
			animation = shock
		} 
	}
	right_portrait = {
		character = scope:inspiration_owner
		triggered_animation = {
			trigger = {
				NOT = { has_trait = chaste }
				is_attracted_to_gender_of = root
			}
			animation = flirtation
		}
		triggered_animation = {
			trigger = {
				NOT = { is_attracted_to_gender_of = root }
			}
			animation = disgust
		}
		triggered_animation = {
			trigger = { has_trait = chaste }
			animation = shock
		}
	}
	cooldown = { years = 10 }

	trigger = {
		is_adult = yes
		exists = scope:inspiration
		might_cheat_on_every_partner_trigger = yes
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			is_attracted_to_gender_of = root
			might_cheat_on_every_partner_trigger = yes
			NOR = {
				has_trait = chaste
				is_consort_of = root
				has_relation_lover = root
				has_relation_soulmate = root
				is_close_family_of = root
				has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
				has_trait = celibate
			}
			opinion = {
				target = root
				value > 0
			}
			might_cheat_on_every_partner_trigger = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_trait = seducer
		}
		modifier = {
			factor = 2
			has_trait = lustful
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_inspiration_cooldown_flag = yes
		}
		hidden_effect = {
			random_list = {
				2 = {
					trigger = {
						NOT = { has_trait = chaste }
						is_attracted_to_gender_of = scope:inspiration_owner
						might_cheat_on_every_partner_trigger = yes
						scope:inspiration_owner = { might_cheat_on_every_partner_trigger = yes }
					}
					modifier = {
						factor = 2
						scope:inspiration_owner = { has_trait = beauty_good }
					}
					modifier = {
						factor = 0.5
						scope:inspiration_owner = { has_trait = beauty_bad }
					}
					modifier = {
						factor = 2
						has_trait = lustful
					}
					modifier = {
						factor = 4
						has_trait = seducer
					}
					add_character_flag = fund_inspiration_2070_instigator
				}
				2 = {
					modifier = {
						factor = 2
						has_trait = beauty_good # root
					}
					modifier = {
						factor = 0.5
						has_trait = beauty_bad # root
					}
					modifier = {
						factor = 2
						scope:inspiration_owner = { has_trait = lustful }
					}
					modifier = {
						factor = 4
						scope:inspiration_owner = { has_trait = seducer }
					}
				}
			}	
		}
		if = {
			limit = { fi_2120_homosexuality_not_accepted_trigger = yes }
			if = { # Their secret
				limit = {
					NOT = { has_character_flag = fund_inspiration_2070_instigator }
					scope:inspiration_owner = {
						trigger_if = {
							limit = { is_male = yes }
							NOT = { has_trait = sodomite }
						}
					}
				}
				scope:inspiration_owner = {
					hidden_effect = { give_homosexual_secret_or_nothing_effect = yes }
					random_secret = {
						limit = { secret_type = secret_homosexual }
						save_scope_as = secret_scope
						if = {
							limit = {
								NOT = { is_known_by = root }
							}
							reveal_to = root
						}
					}
				}
			}
			else_if = { # My secret
				limit = {
					has_character_flag = fund_inspiration_2070_instigator
					trigger_if = {
						limit = { is_male = yes }
						NOT = { has_trait = sodomite }
					}
				}
				hidden_effect = { give_homosexual_secret_or_nothing_effect = yes }
				random_secret = {
					limit = { secret_type = secret_homosexual }
					save_scope_as = secret_scope
					if = {
						limit = {
							NOT = { is_known_by = scope:inspiration_owner }
						}
						reveal_to = scope:inspiration_owner
					}
				}
			}
		}
	}

	option = { # Artisan accepts your seducton
		name = fund_inspiration.2120.a
		trigger = { has_character_flag = fund_inspiration_2070_instigator } # Initiated seduction
		had_sex_with_effect = { CHARACTER = scope:inspiration_owner PREGNANCY_CHANCE = seduce_pregnancy_chance }
		if = {
			limit = {
				can_set_relation_lover_trigger = { CHARACTER = scope:inspiration_owner }
			}
			set_relation_lover = { reason = lover_inspiration_working_late target = scope:inspiration_owner }
		}
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = romance_opinion
				opinion = 15
			}
			change_artifact_quality_effect = { AMOUNT = -2 }
		}
		if = {
			limit = { would_be_sinful_adulterer_trigger = yes }
			stress_impact = {
				zealous = medium_stress_impact_gain
			}
		}
		stress_impact = {
			chaste = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	option = { # Yes to their seduction, generic
		name = fund_inspiration.2120.e
		trigger = {
			NOT = { has_character_flag = fund_inspiration_2070_instigator } # Did not initiate seduction
			OR = {
				is_ai = no
				AND = {
					OR = {
						has_perk = unshackled_lust_perk
						is_attracted_to_gender_of = scope:inspiration_owner
					}
					trigger_if = {
						limit = { relation_with_character_is_sodomy_in_my_or_lieges_faith_trigger = { CHARACTER = scope:inspiration_owner } }
						OR = {
							has_perk = unshackled_lust_perk
							freely_accepts_sodomy_with_trigger = { CHARACTER = scope:inspiration_owner }
						}
					}
					trigger_if = {
						limit = { relation_with_character_is_incestuous_in_my_faith_trigger = { CHARACTER = scope:inspiration_owner } }
						OR = {
							has_perk = subtle_desire_perk
							accepts_incest_with_trigger = { CHARACTER = scope:inspiration_owner }
						}
					}
					might_cheat_on_every_partner_trigger = yes
				}
			}
		}
		had_sex_with_effect = { CHARACTER = scope:inspiration_owner PREGNANCY_CHANCE = seduce_pregnancy_chance }
		if = {
			limit = {
				can_set_relation_lover_trigger = { CHARACTER = scope:inspiration_owner }
			}
			set_relation_lover = { reason = lover_inspiration_working_late target = scope:inspiration_owner }
		}
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = romance_opinion
				opinion = 15
			}
			change_artifact_quality_effect = { AMOUNT = -2 }
		}
		if = {
			limit = { would_be_sinful_adulterer_trigger = yes }
			stress_impact = {
				zealous = medium_stress_impact_gain
			}
		}
		stress_impact = {
			chaste = medium_stress_impact_gain
		}
		if = {
			limit = { exists = scope:secret_scope }
			show_as_tooltip = {
				scope:secret_scope = { reveal_to = root }
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	option = { # No to their seduction, generic
		name = {
			trigger = { 
				OR = {
					has_trait = chaste
					has_trait = celibate
				}
			}
			text = fund_inspiration.2120.f.chaste
		}
		name = {
			trigger = { always = yes }
			text = fund_inspiration.2120.f
		}
		trigger = {
			NOT = { has_character_flag = fund_inspiration_2070_instigator } # Did not initiate seduction
			is_attracted_to_gender_of = scope:inspiration_owner
			fi_2120_homosexuality_not_accepted_trigger = no
			would_be_sinful_adulterer_trigger = no
			scope:inspiration_owner = { would_be_sinful_adulterer_trigger = no }
		}
		flavor =  fund_inspiration.2120.leave_flavor
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = disappointed_opinion
			opinion = -10
		}
		stress_impact = {
			lustful = medium_stress_impact_gain
		}
		if = {
			limit = { exists = scope:secret_scope }
			show_as_tooltip = {
				scope:secret_scope = { reveal_to = root }
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_sociability = -1
			}
		}
	}

	option = { # Lustful attracted to instigator
		name = fund_inspiration.2120.h
		trigger = {
			NOT = { has_character_flag = fund_inspiration_2070_instigator } # Did not initiate seduction
			has_trait = lustful
			is_attracted_to_gender_of = scope:inspiration_owner
		}
		exclusive = yes
		had_sex_with_effect = { CHARACTER = scope:inspiration_owner PREGNANCY_CHANCE = seduce_pregnancy_chance }
		if = {
			limit = {
				can_set_relation_lover_trigger = { CHARACTER = scope:inspiration_owner }
			}
			set_relation_lover = { reason = lover_inspiration_working_late target = scope:inspiration_owner }
		}
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = romance_opinion
				opinion = 15
			}
			change_artifact_quality_effect = { AMOUNT = -2 }
		}
		if = {
			limit = { would_be_sinful_adulterer_trigger = yes }
			stress_impact = {
				zealous = medium_stress_impact_gain
			}
		}
		if = {
			limit = { exists = scope:secret_scope }
			show_as_tooltip = {
				scope:secret_scope = { reveal_to = root }
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_sociability = 1
			}
		}
	}

	option = { # No, because not attracted to them
		name = fund_inspiration.2120.i
		trigger = {
			NOR = {
				has_character_flag = fund_inspiration_2070_instigator # Did not initiate seduction
				is_attracted_to_gender_of = scope:inspiration_owner
			}
		}
		flavor =  fund_inspiration.2120.leave_flavor
		if = {
			limit = { exists = scope:secret_scope }
			show_as_tooltip = {
				scope:secret_scope = { reveal_to = root }
			}
			stress_impact = {
				zealous = medium_stress_impact_gain
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_sociability = -0.5
			}
		}
	}

	option = { # No, because homosexuality not accepted
		name = fund_inspiration.2120.j
		trigger = {
			is_attracted_to_gender_of = scope:inspiration_owner
			fi_2120_homosexuality_not_accepted_trigger = yes
		}
		flavor =  fund_inspiration.2120.leave_flavor
		add_piety = miniscule_piety_gain
		stress_impact = {
			cynical = medium_stress_impact_gain
			lustful = major_stress_impact_gain
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = disappointed_opinion
			opinion = -10
		}
		if = {
			limit = { exists = scope:secret_scope }
			show_as_tooltip = {
				scope:secret_scope = { reveal_to = root }
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_zeal = 1
				ai_sociability = -0.5
			}
		}
	}

	option = { # No, because adultery not accepted
		name = {
			trigger = { is_married = yes }
			text = fund_inspiration.2120.k.me
		}
		name = {
			trigger = {
				scope:inspiration_owner = { is_married = yes }
			}
			text = fund_inspiration.2120.k.them
		}
		trigger = {
			is_attracted_to_gender_of = scope:inspiration_owner
			fi_2120_homosexuality_not_accepted_trigger = no
			OR = {
				would_be_sinful_adulterer_trigger = yes
				scope:inspiration_owner = { would_be_sinful_adulterer_trigger = yes }
			}
		}
		flavor =  fund_inspiration.2120.leave_flavor
		add_piety = miniscule_piety_gain
		stress_impact = {
			cynical = medium_stress_impact_gain
			lustful = major_stress_impact_gain
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = disappointed_opinion
			opinion = -10
		}
		if = {
			limit = { exists = scope:secret_scope }
			show_as_tooltip = {
				scope:secret_scope = { reveal_to = root }
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_zeal = 1
				ai_sociability = -0.5
			}
		}
	}

	option = { # Insulted by instigator's boldness
		name = fund_inspiration.2120.l
		trigger = {
			NOT = { has_character_flag = fund_inspiration_2070_instigator } # Did not initiate seduction
			is_attracted_to_gender_of = scope:inspiration_owner
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = insulted_opinion
			opinion = -20
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = -4 }
		}
		stress_impact = {
			humble = medium_stress_impact_gain
			lustful = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		if = {
			limit = { exists = scope:secret_scope }
			show_as_tooltip = {
				scope:secret_scope = { reveal_to = root }
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = -1
				ai_sociability = -1
			}
		}
	}

	option = { # Reveal instigator's criminal homosexuality
		name = fund_inspiration.2120.m
		trigger = { exists = scope:secret_scope }
		add_piety = minor_piety_gain
		scope:secret_scope = { expose_secret = root }
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = exposed_my_secret_opinion
				opinion = -30
			}
			change_artifact_quality_effect = { AMOUNT = -4 }
		}
		stress_impact = {
			cynical = major_stress_impact_gain
		}
		if = {
			limit = { exists = scope:secret_scope }
			show_as_tooltip = {
				scope:secret_scope = { reveal_to = root }
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = -1
				ai_zeal = 2
			}
		}
	}

	option = { # Back out of seduction, generic
		name = fund_inspiration.2120.f
		trigger = {
			has_character_flag = fund_inspiration_2070_instigator
			NOR = {
				AND = {
					is_attracted_to_gender_of = scope:inspiration_owner
					fi_2120_homosexuality_not_accepted_trigger = no
					OR = {
						would_be_sinful_adulterer_trigger = yes
						scope:inspiration_owner = { would_be_sinful_adulterer_trigger = yes }
					}
				}
				AND = {
					is_attracted_to_gender_of = scope:inspiration_owner
					fi_2120_homosexuality_not_accepted_trigger = yes
				}
			}
		}
		flavor = fund_inspiration.2120.leave_flavor
		stress_impact = {
			lustful = medium_stress_impact_gain
		}
		if = {
			limit = { exists = scope:secret_scope }
			show_as_tooltip = {
				scope:secret_scope = { reveal_to = scope:inspiration_owner }
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_sociability = -1
				ai_boldness = -0.5
			}
		}
	}

	after = {
		if = {
			limit = { has_character_flag = fund_inspiration_2070_instigator }
			remove_character_flag = fund_inspiration_2070_instigator
		}
	}
}

# Helping chain
# by Joe Parkin
scripted_effect fi_2130_lifestyle_effect = {
	random = {
		chance = 33
		scope:inspiration_owner = { add_trait = $TRAIT$ }
		progress_towards_friend_effect = {
			CHARACTER = root
			OPINION = 0
			REASON = friend_inspired_craftsman
		}
	}
}

fund_inspiration.2130 = {
	type = character_event
	title = fund_inspiration.2130.t
	desc = fund_inspiration.2130.desc
	theme = realm
	override_background = {
		reference = corridor_day
	}
	left_portrait = {
		character = root 
	}
	right_portrait = {
		character = scope:inspiration_owner
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
			has_no_inspiration_event_cooldown = yes
			NOR = {
				has_character_flag = had_event_fund_inspiration_2130
				has_variable = banner_commission
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_2130
				years = 5
			}
			add_inspiration_cooldown_flag = yes
		}
		scope:inspiration = {
			if = {
				limit = {
					OR = {
						has_inspiration_type = book_inspiration
						has_inspiration_type = alchemy_inspiration
						has_inspiration_type = research_inspiration
					}
				}
				save_scope_value_as = {
					name = fi_2130_room
					value = flag:fi_2130_library
				}
			}
			else_if = {
				limit = {
					OR = {
						has_inspiration_type = weapon_inspiration
						has_inspiration_type = armor_inspiration
					}
				}
				save_scope_value_as = {
					name = fi_2130_room
					value = flag:fi_2130_armory
				}
			}
		}
	}

	option = { # Help find something
		name = {
			text = fund_inspiration.2130.a.library
			trigger = {
				exists = scope:fi_2130_room 
				scope:fi_2130_room = flag:fi_2130_library
			}
		}
		name = {
			text = fund_inspiration.2130.a.armory
			trigger = {
				exists = scope:fi_2130_room 
				scope:fi_2130_room = flag:fi_2130_armory
			}
		}
		name = {
			text = fund_inspiration.2130.a.hall
			trigger = {
				NOT = { exists = scope:fi_2130_room }
			}
		}
		flavor = fund_inspiration.2130.a.flavor
		custom_tooltip = fund_inspiration.2130.a.tt
		trigger_event = {
			id = fund_inspiration.2131
			days = 3
		}
		stress_impact = {
			lazy = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
		}
	}

	option = { # Do this
		name = fund_inspiration.2130.b
		flavor = fund_inspiration.2130.b.flavor
		trigger = {
			OR = {
				has_trait = drunkard
				has_trait = hashishiyah
				has_trait = rakish
				has_trait = lifestyle_reveler
				has_trait = lifestyle_hunter
				has_trait = lifestyle_gardener
				has_trait = athletic
			}
		}
		if = {
			limit = {
				OR = {
					has_trait = drunkard
					has_trait = hashishiyah
					has_trait = lifestyle_reveler
				}
			}
			scope:inspiration_owner = {
				if = {
					limit = { has_trait = temperate }
					stress_impact = { temperate = medium_stress_impact_gain }
				}
			}
		}
		if = {
			limit = {
				OR = {
					has_trait = lifestyle_reveler
					has_trait = rakish
				}
			}
			scope:inspiration_owner = {
				if = {
					limit = { has_trait = shy }
					stress_impact = { temperate = medium_stress_impact_gain }
				}
			}
		}
		if = {
			limit = {
				OR = {
					has_trait = lifestyle_hunter
					has_trait = athletic
					has_trait = lifestyle_gardener
				}
			}
			scope:inspiration_owner = {
				if = {
					limit = { has_trait = lazy }
					stress_impact = { lazy = medium_stress_impact_gain }
				}
			}
		}
		if = {
			limit = { has_trait = lifestyle_hunter }
			scope:inspiration_owner = {
				if = {
					limit = { has_trait = craven }
					stress_impact = { craven = medium_stress_impact_gain }
				}
			}
		}
		if = {
			limit = {
				scope:inspiration_owner = {
					NOR = {
						has_trait = drunkard
						has_trait = hashishiyah
						has_trait = lifestyle_reveler
						has_trait = rakish
						has_trait = lifestyle_hunter
						has_trait = athletic
						has_trait = lifestyle_gardener
					}
				}
			}
			if = {
				limit = { has_trait = drunkard }
				fi_2130_lifestyle_effect = { TRAIT = drunkard }
			}
			else_if = {
				limit = { has_trait = hashishiyah }
				fi_2130_lifestyle_effect = { TRAIT = hashishiyah }
			}
			else_if = {
				limit = { has_trait = rakish }
				fi_2130_lifestyle_effect = { TRAIT = rakish }
			}
			else_if = {
				limit = { has_trait = lifestyle_reveler }
				fi_2130_lifestyle_effect = { TRAIT = lifestyle_reveler }
			}
			else_if = {
				limit = { has_trait = lifestyle_hunter }
				fi_2130_lifestyle_effect = { TRAIT = lifestyle_hunter }
			}
			else_if = {
				limit = { has_trait = athletic }
				fi_2130_lifestyle_effect = { TRAIT = athletic }
			}
			else = {
				fi_2130_lifestyle_effect = { TRAIT = lifestyle_gardener }
			}
		}
		random_list = {
			5 = {
				send_interface_toast = {
					title = fund_inspiration.2130.b.great
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = 2 }
						inspiration = { change_inspiration_progress = 1 }
					}
				}
			}
			5 = {
				send_interface_toast = {
					title = fund_inspiration.2130.b.good
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						inspiration = { change_inspiration_progress = 1 }
					}
				}
			}
			20 = {
				send_interface_toast = {
					title = fund_inspiration.2130.b.nothing
					left_icon = scope:inspiration_owner
				}
			}
			15 = {
				send_interface_toast = {
					title = fund_inspiration.2130.b.bad
					left_icon = scope:inspiration_owner
					scope:inspiration = { change_inspiration_progress = -1 }
				}
			}
			5 = {
				send_interface_toast = {
					title = fund_inspiration.2130.b.terrible
					left_icon = scope:inspiration_owner
					scope:inspiration = { change_inspiration_progress = -2 }
				}
			}
		}
		stress_impact = {
			lazy = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
		}
	}

	option = { # Take this
		name = fund_inspiration.2130.c
		flavor = fund_inspiration.2130.c.flavor
		trigger = {
			OR = {
				OR = {
					has_trait = witch
					any_secret = { secret_type = secret_witch }
				}
				has_trait = lifestyle_herbalist
				has_trait = lifestyle_physician
				has_trait = lifestyle_mystic
			}
		}
		if = {
			limit = {
				NOR = {
					has_trait = lifestyle_herbalist
					has_trait = lifestyle_physician
					has_trait = lifestyle_mystic
				}
				any_secret = {
					secret_type = secret_witch
					NOT = { is_known_by = scope:inspiration_owner }
				}
				scope:inspiration_owner = { is_alive = yes}
			}
			random = {
				chance = 33
				random_secret = {
					limit = {
						secret_type = secret_witch
						NOT = { is_known_by = scope:inspiration_owner }
					}
					reveal_to = scope:inspiration_owner
				}
			}
		}
		random_list = {
			5 = { # Miracle
				send_interface_toast = {
					title = fund_inspiration.2130.b.great
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = 2 }
						inspiration = { change_inspiration_progress = 2 }
					}
				}
			}
			9 = { # Placebo
				send_interface_toast = {
					title = fund_inspiration.2130.b.good
					left_icon = scope:inspiration_owner
					scope:inspiration = { change_inspiration_progress = 1 }
				}
			}
			15 = { # Homeopathy
				send_interface_toast = {
					title = fund_inspiration.2130.b.nothing
					left_icon = scope:inspiration_owner
				}
			}
			5 = { # Stupidity
				send_interface_toast = {
					title = fund_inspiration.2130.b.bad
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
						inspiration = { change_inspiration_progress = -1 }
					}
				}
			}
			1 = { # Gross Negligence
				send_interface_toast = {
					title = fund_inspiration.2130.c.dead
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						death = { death_reason = death_strongest_potion }
					}
				}	
			}
		}
		stress_impact = {
			lazy = medium_stress_impact_gain
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
		}
	}

	option = { # Oh well
		name = fund_inspiration.2130.d
		scope:inspiration = { change_inspiration_progress = -1 }
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = annoyed_opinion
			opinion = -10
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			diligent = medium_stress_impact_gain
			generous = medium_stress_impact_gain
			humble = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
		}
	}
}

scripted_trigger fi_2131_artifact_type_trigger = {
	NAND = {
		exists = scope:artifact_1
		this = scope:artifact_1
	}
	is_unique = no
	artifact_durability > define:NInventory|ARTIFACT_VERY_LOW_DURABILITY
	# LIBRARY
	trigger_if = {
		limit = {
			exists = scope:fi_2130_room
			scope:fi_2130_room = flag:fi_2130_library
		}
		trigger_if = {
			limit = {
				scope:inspiration = { 
					OR = {
						has_inspiration_type = book_inspiration 
						has_inspiration_type = research_inspiration
					}
				}
			}
			artifact_type = book
		}
		trigger_else = {
			OR = {
				artifact_type = elixir
				artifact_type = panacea
			}
		}
	}
	# ARMORY
	trigger_else_if = {
		limit = {
			exists = scope:fi_2130_room
			scope:fi_2130_room = flag:fi_2130_armory
		}
		OR = {
			artifact_slot_type = primary_armament
			artifact_slot_type = armor
			artifact_slot_type = helmet
		}
	}
	# HALL
	trigger_else = {
		trigger_if = {
			limit = {
				scope:inspiration = { has_inspiration_type = smith_inspiration }
			}
			OR = {
				artifact_type = regalia
				artifact_type = brooch
				artifact_type = necklace
			}
		}
		trigger_else_if = {
			limit = {
				scope:inspiration = { has_inspiration_type = weaver_inspiration }
			}
			OR = {
				artifact_type = tapestry
				artifact_type = wall_big
			}
		}
		trigger_else_if = {
			limit = { scope:inspiration_owner.var:artifact_artisan_type = flag:artisan_type_sculpture }
			artifact_type = sculpture
		}
		trigger_else = {
			OR = {
				artifact_type = cabinet
				artifact_type = chest
				artifact_type = throne
			}
		}
	}
}

fund_inspiration.2131 = {
	type = character_event
	title = fund_inspiration.2131.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:fi_2130_room
					scope:fi_2130_room = flag:fi_2130_library
					NOR = {
						has_trait = education_learning
						has_lifestyle = learning_lifestyle
						learning >= decent_skill_rating
						has_trait = scholar
						has_trait = theologian
						has_trait = lifestyle_mystic
						has_trait = lifestyle_physician
						has_trait = lifestyle_herbalist
					}
				}
				desc = fund_inspiration.2131.desc_library_unused
			}
			triggered_desc = {
				trigger = {
					exists = scope:fi_2130_room
					scope:fi_2130_room = flag:fi_2130_library
				}
				desc = fund_inspiration.2131.desc_library
			}
			triggered_desc = {
				trigger = {
					exists = scope:fi_2130_room
					scope:fi_2130_room = flag:fi_2130_armory
					NOR = {
						has_trait = education_martial
						has_lifestyle = martial_lifestyle
						martial >= decent_skill_rating
						prowess >= decent_skill_rating
						has_trait = viking
						has_trait = faith_warrior
						has_trait = crusader_king
						has_trait = lifestyle_blademaster
				 		has_trait = lifestyle_hunter
						has_trait = berserker
				 		has_trait = shieldmaiden
					}
				}
				desc = fund_inspiration.2131.desc_armory_unused 
			}
			triggered_desc = {
				trigger = {
					exists = scope:fi_2130_room
					scope:fi_2130_room = flag:fi_2130_armory
				}
				desc = fund_inspiration.2131.desc_armory 
			}
			triggered_desc = {
				trigger = { court_grandeur_current_level < court_grandeur_minimum_expected_level }
				desc = fund_inspiration.2131.desc_great_hall_low 
			}
			desc = fund_inspiration.2131.desc_great_hall 
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:second
					scope:second = { has_court_position = antiquarian_court_position }
				}
				desc = fund_inspiration.2131.desc_antiquarian
			}
			triggered_desc = {
				trigger = {
					exists = scope:second
					scope:second = { has_court_position = court_artificer_court_position }
				}
				desc = fund_inspiration.2131.artificer
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:artifact_1
					scope:artifact_1 = { is_equipped = yes }
				}
				desc = fund_inspiration.2131.desc_equipped
			}
			triggered_desc = {
				trigger = { exists = scope:artifact_1 }
				desc = fund_inspiration.2131.desc_unequipped
			}
			desc = fund_inspiration.2131.desc_fallback
		}
	}
	theme = realm
	override_background = {
		trigger = {
			exists = scope:fi_2130_room
			scope:fi_2130_room = flag:fi_2130_library
		}
		reference = study
	}
	override_background = {
		trigger = {
			exists = scope:fi_2130_room
			scope:fi_2130_room = flag:fi_2130_armory
		}
		reference = armory
	}
	override_background = {
		trigger = {
			NOT = { exists = scope:fi_2130_room }
		}
		reference = throne_room
	}
	left_portrait = {
		character = scope:inspiration_owner
		triggered_animation = {
	 		trigger = { exists = scope:artifact_1 }
	  		animation = shock
 		}
 		triggered_animation = {
	 		trigger = {
	 			NOT = { exists = scope:artifact_1 }
	 		}
	  		animation = stress
 		}
	}
	right_portrait = {
		character = scope:second
		triggered_animation = {
	 		trigger = { has_court_position = antiquarian_court_position }
	  		animation = worry
 		}
 		triggered_animation = {
	 		trigger = { has_court_position = court_artificer_court_position }
	  		animation = happiness
 		}
	}
	artifact = { # To display the artifact in the event-window
		target = scope:artifact_1
		position = lower_center_portrait
	}
	artifact = { # To display the artifact in the event-window
		target = scope:artifact_2
		position = lower_right_portrait
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			#These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
			fund_inspiration_court_inspiration_owner_trigger = yes
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_inspiration_cooldown_flag = yes
		}
		if = {
			limit = {
				any_character_artifact = { fi_2131_artifact_type_trigger = yes }
			}
			random_character_artifact = {
				limit = {
					is_equipped = yes
					fi_2131_artifact_type_trigger = yes
				}
				alternative_limit = { fi_2131_artifact_type_trigger = yes }
				weight = {
					base = 1
					modifier = {
						factor = 2
						NOT = {
							root = { can_benefit_from_artifact = prev }
						}
					}
				}
				save_scope_as = artifact_1
			}
		}
		if = {
			limit = {
				any_equipped_character_artifact = { fi_2131_artifact_type_trigger = yes }
			}
			random_equipped_character_artifact = {
				limit = {
					is_equipped = no
					fi_2131_artifact_type_trigger = yes
				}
				alternative_limit = { fi_2131_artifact_type_trigger = yes }
				weight = {
					base = 1
					modifier = {
						factor = 2
						NOT = {
							root = { can_benefit_from_artifact = prev }
						}
					}
				}
				save_scope_as = artifact_2
			}
		}
		hidden_effect = {
			random_list = {
				2 = {
					trigger = {
						any_court_position_holder = {
							type = antiquarian_court_position
							is_available_healthy_ai_adult = yes
							NOT = { this = scope:inspiration_owner }
						}
					}
					random_court_position_holder = {
					 	type = antiquarian_court_position
						limit = {
							is_available_healthy_ai_adult = yes
							NOT = { this = scope:inspiration_owner }
						}
						save_scope_as = second
					}
				}
				2 = {
					trigger = {
						any_court_position_holder = {
							type = court_artificer_court_position
							is_available_healthy_ai_adult = yes
							NOT = { this = scope:inspiration_owner }
						}
					}
					random_court_position_holder = {
					 	type = court_artificer_court_position
						limit = {
							is_available_healthy_ai_adult = yes
							NOT = { this = scope:inspiration_owner }
						}
						save_scope_as = second
					}
				}
			}
		}
	}

	option = { # 1st artifact
		name = fund_inspiration.2131.a
		trigger = { exists = scope:artifact_1 }
		scope:inspiration_owner = {
			if = {
				limit = {
					scope:artifact_1 = {
						OR = {
							AND = {
								exists = var:quality
								var:quality > 50
							}
							OR = {
								rarity = famed
								rarity = illustrious
							}
						}
					}
				}
				change_artifact_quality_effect = { AMOUNT = 8 }
				inspiration = { change_inspiration_progress = 1 }
				root = {
					reverse_add_opinion = {
						target = scope:inspiration_owner
						modifier = grateful_opinion
						opinion = 20
					}
					stress_impact = { greedy = medium_stress_impact_gain }
				}
			}
			else = {
				change_artifact_quality_effect = { AMOUNT = 4 }
				root = {
					reverse_add_opinion = {
						target = scope:inspiration_owner
						modifier = grateful_opinion
						opinion = 10
					}
					stress_impact = { greedy = minor_stress_impact_gain }
				}
			}
		}
		destroy_artifact = scope:artifact_1
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_greed = -2
				ai_boldness = 2
				ai_rationality = -2
			}
		}
	}

	option = { # 2nd artifact
		name = fund_inspiration.2131.b
		trigger = { exists = scope:artifact_2 }
		scope:inspiration_owner = {
			if = {
				limit = {
					scope:artifact_2 = {
						OR = {
							AND = {
								exists = var:quality
								var:quality > 50
							}
							OR = {
								rarity = famed
								rarity = illustrious
							}
						}
					}
				}
				change_artifact_quality_effect = { AMOUNT = 8 }
				inspiration = { change_inspiration_progress = 1 }
				root = {
					reverse_add_opinion = {
						target = scope:inspiration_owner
						modifier = grateful_opinion
						opinion = 20
					}
					stress_impact = { greedy = medium_stress_impact_gain }
				}
			}
			else = {
				change_artifact_quality_effect = { AMOUNT = 4 }
				root = {
					reverse_add_opinion = {
						target = scope:inspiration_owner
						modifier = grateful_opinion
						opinion = 10
					}
					stress_impact = { greedy = minor_stress_impact_gain }
				}
			}
			destroy_artifact = scope:artifact_2
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_greed = -2
				ai_boldness = 2
				ai_rationality = -2
			}
		}
	}

	option = { # Melt down random stuff
		name = fund_inspiration.2131.c
		trigger = {
			NOR = {
				exists = scope:artifact_1
				exists = scope:artifact_2
			}
		}
		random_list = {
			10 = {
				send_interface_toast = {
					title = fund_inspiration.2131.d.good
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = 2 }
					}
					reverse_add_opinion = {
						target = scope:inspiration_owner
						modifier = pleased_opinion
						opinion = 5
					}
				}
			}
			20 = {
				send_interface_toast = {
					title = fund_inspiration.2131.d.nothing
					left_icon = scope:inspiration_owner
					reverse_add_opinion = {
						target = scope:inspiration_owner
						modifier = disappointed_opinion
						opinion = -5
					}
				}
			}
			50 = {
				send_interface_toast = {
					title = fund_inspiration.2131.d.bad
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = -2 }
					}
					reverse_add_opinion = {
						target = scope:inspiration_owner
						modifier = annoyed_opinion
						opinion = -10
					}
				}
			}
		}
		stress_impact = {
			lazy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 1
				ai_boldness = 0.5
				ai_rationality = -0.5
			}
		}
	}

	option = { # Look only
		name = fund_inspiration.2131.d
		trigger = { exists = scope:artifact_1 }
		scope:inspiration = { change_inspiration_progress = 1 }
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = grateful_opinion
			opinion = 5
		}
		stress_impact = {
			lazy = medium_stress_impact_gain
			generous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 1
				ai_boldness = -1
				ai_rationality = 1
			}
		}
	}

	option = { # Antiquarian helps
		name = fund_inspiration.2131.e
		trigger = {
			NOT = { exists = scope:artifact_1 }
			exists = scope:second
		}
		reverse_add_opinion = {
			target = scope:second
			modifier = pleased_opinion
			opinion = 5
		}
		random_list = {
			5 = {
				send_interface_toast = {
					title = fund_inspiration.2131.d.great
					left_icon = scope:inspiration_owner
					right_icon = scope:second
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = 4 }
					}
				}
			}
			25 = {
				send_interface_toast = {
					title = fund_inspiration.2131.d.good
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = 2 }
					}
				}
			}
			20 = {
				send_interface_toast = {
					title = fund_inspiration.2131.d.nothing
					left_icon = scope:inspiration_owner
				}
			}
			50 = {
				send_interface_toast = {
					title = fund_inspiration.2131.d.bad
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = -2 }
					}
				}
			}
			5 = {
				send_interface_toast = {
					title = fund_inspiration.2131.d.terrible
					left_icon = scope:inspiration_owner
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = -4 }
					}
				}
				modifier = {
					factor = 10
					OR = {
						scope:inspiration_owner = { has_relation_rival = scope:second }
						has_relation_rival = scope:second
					}
				}
			}
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 1
				ai_boldness = -0.5
				ai_rationality = 0.5
			}
		}
	}

	option = { # Give up
		name = fund_inspiration.2131.f
		trigger = {
			NOT = { exists = scope:artifact_1 }
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = disappointed_opinion
			opinion = -10
		}
		stress_impact = {
			diligent = medium_stress_impact_gain
			patient = medium_stress_impact_gain
			greedy = medium_stress_impact_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -1
				ai_energy = -1
			}
		}
	}
}

# Court Chaplain complains about book subject
# by Linnéa Thimrén
scripted_trigger fund_inspiration_3001_witch_topic_trigger = {
	exists = scope:inspiration_owner.var:book_subject
	scope:inspiration_owner.var:book_subject = flag:witch
	trait_is_shunned_or_criminal_in_faith_trigger = {
		TRAIT = witch
		GENDER_CHARACTER = root
		FAITH = root.faith
	}
}
scripted_trigger fund_inspiration_3001_cannibal_topic_trigger = {
	exists = scope:inspiration_owner.var:book_subject
	scope:inspiration_owner.var:book_subject = flag:cannibal
	trait_is_criminal_in_faith_trigger = {
		TRAIT = cannibal
		GENDER_CHARACTER = root
		FAITH = root.faith
	}
}
scripted_trigger fund_inspiration_3001_deviant_topic_trigger = {
	exists = scope:inspiration_owner.var:book_subject
	scope:inspiration_owner.var:book_subject = flag:deviant
	trait_is_shunned_or_criminal_in_faith_trigger = {
		TRAIT = deviant
		GENDER_CHARACTER = root
		FAITH = root.faith
	}
}
scripted_trigger fund_inspiration_3001_torturer_topic_trigger = {
	exists = scope:inspiration_owner.var:book_subject
	scope:inspiration_owner.var:book_subject = flag:torturer
}
scripted_trigger fund_inspiration_3001_lustful_topic_trigger = {
	exists = scope:inspiration_owner.var:book_subject
	exists = scope:inspiration_owner.var:book_topic
	OR = {
		scope:inspiration_owner.var:book_topic = flag:intrigue_the_art_of_love
		scope:inspiration_owner.var:book_topic = flag:seduction
		scope:inspiration_owner.var:book_topic = flag:fertility
		scope:inspiration_owner.var:book_topic = flag:love_sorcery
	}
	faith = { trait_is_sin = lustful }
}

fund_inspiration.3001 = {
	type = character_event
	title = fund_inspiration.3001.t
	desc = {
		desc = fund_inspiration.3001.desc_opening
		first_valid = {
			triggered_desc = {
				trigger = {
					fund_inspiration_3001_witch_topic_trigger = yes
				}
				desc = fund_inspiration.3001.desc_witch
			}
			triggered_desc = {
				trigger = {
					fund_inspiration_3001_cannibal_topic_trigger = yes
				}
				desc = fund_inspiration.3001.desc_cannibal
			}
			triggered_desc = {
				trigger = {
					fund_inspiration_3001_torturer_topic_trigger = yes
				}
				desc = fund_inspiration.3001.desc_torturer
			}
			triggered_desc = {
				trigger = {
					OR = {
						fund_inspiration_3001_lustful_topic_trigger = yes
						fund_inspiration_3001_deviant_topic_trigger = yes
					}
				}
				desc = fund_inspiration.3001.desc_lustful
			}
			desc = fund_inspiration.3001.desc_other
		}
		desc = fund_inspiration.3001.desc_ending
	}
	theme = realm
	override_background = {
		reference = study
	}
	left_portrait = {
		character = scope:court_chaplain
		animation = disapproval
	}
	right_portrait = {
		character = scope:inspiration_owner
		animation = anger
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			has_inspiration_type = book_inspiration
			inspiration_owner = {
				is_available_ai_adult = yes
				has_no_inspiration_event_cooldown = yes
				NOT = { has_character_flag = had_event_fund_inspiration_3001 }
				exists = var:book_subject
				trigger_if = { #If they're writing about learning they're not writing about faith
					limit = {
						var:book_subject = flag:learning
					}
					exists = var:book_topic_category
					NOT = { var:book_topic_category = flag:learning_faith }
				}
			}
		}
		exists = cp:councillor_court_chaplain
		cp:councillor_court_chaplain = { is_available_ai_adult = yes }
	}

	weight_multiplier = {
		base = 0.1 #Very unlikely if you're just writing about whatever
		modifier = { #A bit more likely if the court chaplain is a zealot
			add = 0.5
			cp:councillor_court_chaplain = { has_trait = zealous }
		}
		#More likely if they're writing about something "bad"
		modifier = {
			add = 2
			OR = {
				fund_inspiration_3001_witch_topic_trigger = yes
				fund_inspiration_3001_cannibal_topic_trigger = yes
				fund_inspiration_3001_deviant_topic_trigger = yes
				fund_inspiration_3001_torturer_topic_trigger = yes
				fund_inspiration_3001_lustful_topic_trigger = yes
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_3001
				years = 20
			}
			#To stagger any following events
			add_inspiration_cooldown_flag = yes
		}
		cp:councillor_court_chaplain = {
			save_scope_as = court_chaplain
		}
	}

	#Write about faith instead
	option = {
		name = fund_inspiration.3001.a
		add_piety = minor_piety_gain
		scope:court_chaplain = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
		}
		scope:inspiration_owner = {
			custom_tooltip = fund_inspiration.3001.a_tt
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -20
			}
			change_artifact_quality_effect = {
				AMOUNT = -4
			}
			remove_variable = book_subject
			set_variable = {
				name = book_subject
				value = flag:learning
			}
			set_variable = {
				name = book_topic_category
				value = flag:learning_faith
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_zeal = 0.75
			}
		}
	}

	#Tell court chaplain to back off
	option = {
		name = fund_inspiration.3001.b
		scope:court_chaplain = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -20
			}
		}
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}

	#Invest even more into the book
	option = {
		name = fund_inspiration.3001.c
		scope:inspiration = { invest_gold = 25 }
		scope:court_chaplain = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -40
			}
		}
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 40
			}
			change_artifact_quality_effect = {
				AMOUNT = 4
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.75
				ai_zeal = -0.5
				ai_vengefulness = 0.5
			}
			modifier = {
				factor = 0
				short_term_gold < 25
			}
		}
	}
}

# Book (Martial) - wanna nudge the content?
# by Linnéa Thimrén
fund_inspiration.3011 = {
	type = character_event
	title = fund_inspiration.3011.t
	desc = {
		random_valid = {
			desc = fund_inspiration.3011.desc_opening_1
			desc = fund_inspiration.3011.desc_opening_2
			desc = fund_inspiration.3011.desc_opening_3
		}
		desc = fund_inspiration.3011.desc
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_rational
	}

	trigger = {
		exists = scope:inspiration
		is_ai = no #Topic for AIs is handled in the artifact-generation effect
		scope:inspiration = {
			has_inspiration_type = book_inspiration
			inspiration_owner = { #They have already decided what to write about
				is_available_ai_adult = yes
				exists = var:book_subject
				var:book_subject = flag:martial
				NOR = { #These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
					exists = var:book_topic
					exists = var:book_topic_category
					has_character_flag = had_event_fund_inspiration_3011
					has_character_flag = fund_book_inspiration_event_cooldown
				}
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_3011
				years = 20
			}

			#To stagger any following events
			add_character_flag = {
				flag = fund_book_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
	}

	#Strategy
	option = {
		name = fund_inspiration.3011.a
		custom_tooltip = fund_inspiration.3011.a.tt
		scope:inspiration_owner = {
			set_variable = {
				name = book_topic_category
				value = flag:martial_strategy
			}
		}
	}

	#Chivalry/prowess
	option = {
		name = fund_inspiration.3011.b
		custom_tooltip = fund_inspiration.3011.b.tt
		scope:inspiration_owner = {
			set_variable = {
				name = book_topic_category
				value = flag:martial_chivalry_prowess
			}
		}
	}

	#I don't care
	option = {
		name = fund_inspiration.3011.d
		custom_tooltip = fund_inspiration.3011.d.tt
		scope:inspiration_owner = {
			change_artifact_book_content_quality_effect = {
				AMOUNT = 2
			}
		}
	}
}

# Book (Diplomacy) - wanna nudge the content?
# by Linnéa Thimrén
fund_inspiration.3012 = {
	type = character_event
	title = fund_inspiration.3012.t
	desc = {
		random_valid = {
			desc = fund_inspiration.3011.desc_opening_1
			desc = fund_inspiration.3011.desc_opening_2
			desc = fund_inspiration.3011.desc_opening_3
		}
		desc = fund_inspiration.3012.desc
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_rational
	}

	trigger = {
		exists = scope:inspiration
		is_ai = no #Topic for AIs is handled in the artifact-generation effect
		scope:inspiration = {
			has_inspiration_type = book_inspiration
			inspiration_owner = { #They have already decided what to write about
				is_available_ai_adult = yes
				exists = var:book_subject
				var:book_subject = flag:diplomacy
				NOR = { #These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
					exists = var:book_topic
					exists = var:book_topic_category
					has_character_flag = had_event_fund_inspiration_3012
					has_character_flag = fund_book_inspiration_event_cooldown
				}
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_3012
				years = 20
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_book_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
	}

	#Court
	option = {
		name = fund_inspiration.3012.a
		custom_tooltip = fund_inspiration.3012.a.tt
		scope:inspiration_owner = {
			set_variable = {
				name = book_topic_category
				value = flag:diplomacy_court
			}
		}
	}

	#Entertainment
	option = {
		name = fund_inspiration.3012.b
		custom_tooltip = fund_inspiration.3012.b.tt
		scope:inspiration_owner = {
			set_variable = {
				name = book_topic_category
				value = flag:diplomacy_entertainment
			}
		}
	}

	#Go with what you know
	option = {
		name = fund_inspiration.3011.d
		custom_tooltip = fund_inspiration.3011.d.tt
		scope:inspiration_owner = {
			change_artifact_book_content_quality_effect = {
				AMOUNT = 2
			}
		}
	}
}

# Book (Learning) - wanna nudge the content?
# by Linnéa Thimrén
fund_inspiration.3013 = {
	type = character_event
	title = fund_inspiration.3013.t
	desc = {
		random_valid = {
			desc = fund_inspiration.3011.desc_opening_1
			desc = fund_inspiration.3011.desc_opening_2
			desc = fund_inspiration.3011.desc_opening_3
		}
		desc = fund_inspiration.3013.desc
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_rational
	}

	trigger = {
		exists = scope:inspiration
		is_ai = no #Topic for AIs is handled in the artifact-generation effect
		scope:inspiration = {
			has_inspiration_type = book_inspiration
			inspiration_owner = { #They have already decided what to write about
				is_available_ai_adult = yes
				exists = var:book_subject
				var:book_subject = flag:learning
				NOR = { #These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
					exists = var:book_topic
					exists = var:book_topic_category
					has_character_flag = had_event_fund_inspiration_3013
					has_character_flag = fund_book_inspiration_event_cooldown
				}
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_3013
				years = 20
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_book_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
	}

	#Faith
	option = {
		name = fund_inspiration.3013.a
		custom_tooltip = fund_inspiration.3013.a.tt
		scope:inspiration_owner = {
			set_variable = {
				name = book_topic_category
				value = flag:learning_faith
			}
		}
	}

	#Learning/poetry
	option = {
		name = fund_inspiration.3013.b
		custom_tooltip = fund_inspiration.3013.b.tt
		scope:inspiration_owner = {
			set_variable = {
				name = book_topic_category
				value = flag:learning_learning
			}
		}
	}

	#Go with what you know
	option = {
		name = fund_inspiration.3011.d
		custom_tooltip = fund_inspiration.3011.d.tt
		scope:inspiration_owner = {
			change_artifact_book_content_quality_effect = {
				AMOUNT = 2
			}
		}
	}
}

# Book (Stewardship) - wanna nudge the content?
# by Linnéa Thimrén
fund_inspiration.3014 = {
	type = character_event
	title = fund_inspiration.3014.t
	desc = {
		random_valid = {
			desc = fund_inspiration.3011.desc_opening_1
			desc = fund_inspiration.3011.desc_opening_2
			desc = fund_inspiration.3011.desc_opening_3
		}
		desc = fund_inspiration.3014.desc
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_rational
	}

	trigger = {
		exists = scope:inspiration
		is_ai = no #Topic for AIs is handled in the artifact-generation effect
		scope:inspiration = {
			has_inspiration_type = book_inspiration
			inspiration_owner = { #They have already decided what to write about
				is_available_ai_adult = yes
				exists = var:book_subject
				var:book_subject = flag:stewardship
				NOR = { #These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
					exists = var:book_topic
					exists = var:book_topic_category
					has_character_flag = had_event_fund_inspiration_3014
					has_character_flag = fund_book_inspiration_event_cooldown
				}
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_3014
				years = 20
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_book_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
	}

	#Rule
	option = {
		name = fund_inspiration.3014.a
		custom_tooltip = fund_inspiration.3014.a.tt
		scope:inspiration_owner = {
			set_variable = {
				name = book_topic_category
				value = flag:stewardship_rule
			}
		}
	}

	#Development
	option = {
		name = fund_inspiration.3014.b
		custom_tooltip = fund_inspiration.3014.b.tt
		scope:inspiration_owner = {
			set_variable = {
				name = book_topic_category
				value = flag:stewardship_development
			}
		}
	}

	#Go with what you know
	option = {
		name = fund_inspiration.3011.d
		custom_tooltip = fund_inspiration.3011.d.tt
		scope:inspiration_owner = {
			change_artifact_book_content_quality_effect = {
				AMOUNT = 2
			}
		}
	}
}

# Book (Intrigue) - wanna nudge the content?
# by Linnéa Thimrén
fund_inspiration.3015 = {
	type = character_event
	title = fund_inspiration.3015.t
	desc = {
		random_valid = {
			desc = fund_inspiration.3011.desc_opening_1
			desc = fund_inspiration.3011.desc_opening_2
			desc = fund_inspiration.3011.desc_opening_3
		}
		desc = fund_inspiration.3015.desc
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_rational
	}

	trigger = {
		exists = scope:inspiration
		is_ai = no #Topic for AIs is handled in the artifact-generation effect
		scope:inspiration = {
			has_inspiration_type = book_inspiration
			inspiration_owner = { #They have already decided what to write about
				is_available_ai_adult = yes
				exists = var:book_subject
				var:book_subject = flag:intrigue
				NOR = { #These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
					exists = var:book_topic
					exists = var:book_topic_category
					has_character_flag = had_event_fund_inspiration_3015
					has_character_flag = fund_book_inspiration_event_cooldown
				}
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_3015
				years = 20
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_book_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
	}

	#Scheme
	option = {
		name = fund_inspiration.3015.a
		custom_tooltip = fund_inspiration.3015.a.tt
		scope:inspiration_owner = {
			set_variable = {
				name = book_topic_category
				value = flag:intrigue_scheme
			}
		}
	}

	#Seduction
	option = {
		name = {
			trigger = {
				is_attracted_to_men = yes
				is_attracted_to_women = no
			}
			text = fund_inspiration.3015.b_men
		}
		name = {
			trigger = {
				is_attracted_to_women = yes
				is_attracted_to_men = no
			}
			text = fund_inspiration.3015.b_women
		}
		name = {
			trigger = {
				is_attracted_to_men = yes
				is_attracted_to_women = yes
			}
			text = fund_inspiration.3015.b_both
		}
		name = {
			trigger = {
				is_attracted_to_men = no
				is_attracted_to_women = no
			}
			text = fund_inspiration.3015.b_none
		}
		trigger = {
			is_adult = yes #Just to make sure
		}
		custom_tooltip = fund_inspiration.3015.b.tt
		scope:inspiration_owner = {
			set_variable = {
				name = book_topic_category
				value = flag:intrigue_seduction
			}
		}
	}

	#Go with what you know
	option = {
		name = fund_inspiration.3011.d
		custom_tooltip = fund_inspiration.3011.d.tt
		scope:inspiration_owner = {
			change_artifact_book_content_quality_effect = {
				AMOUNT = 2
			}
		}
	}
}

# Book - Nemesis is no longer nemesis and you're writing about your hatred
# by Linnéa Thimrén
fund_inspiration.3030 = {
	title = fund_inspiration.3030.t
	type = character_event
	desc = {
		desc = fund_inspiration.3030.desc_opening
		desc = {
			first_valid = {
				triggered_desc = {
					trigger = {
						scope:prev_nemesis = { is_alive = yes }
					}
					desc = fund_inspiration.3030.desc
				}
				desc = fund_inspiration.3030.desc_dead
			}
		}
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_coward
	}
	right_portrait = scope:prev_nemesis

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			has_inspiration_type = book_inspiration
			inspiration_owner = {
				exists = var:book_subject
				var:book_subject = flag:relationship
				exists = var:book_topic
				var:book_topic = flag:nemesis
				exists = var:book_topic_relationship
				var:book_topic_relationship = {
					NOT = { has_relation_nemesis = root } #You're no longer their nemesis :(
				}
				NOT = { has_character_flag = had_event_fund_inspiration_3030 }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_3030
				years = 20
			}
		}
		scope:inspiration_owner.var:book_topic_relationship = {
			save_scope_as = prev_nemesis
		}
	}

	# Continue writing
	option = {
		name = fund_inspiration.3030.a
		custom_tooltip = fund_inspiration.3030.a.tt
		add_stress = medium_stress_gain
		ai_chance = {
			base = 0
		}
	}

	# Scrap it
	option = {
		name = fund_inspiration.3030.b
		end_inspiration_sponsorship = scope:inspiration
		#Let them start over
		inspiration_completion_effect = yes
		ai_chance = {
			base = 100
		}
	}
}

# Book - Soulmate is no longer soulmate and you're writing about your love
# by Linnéa Thimrén
fund_inspiration.3031 = {
	type = character_event
	title = fund_inspiration.3031.t
	desc = {
		desc = fund_inspiration.3030.desc_opening
		desc = {
			first_valid = {
				triggered_desc = {
					trigger = {
						scope:prev_soulmate = { is_alive = yes }
					}
					desc = fund_inspiration.3031.desc
				}
				desc = fund_inspiration.3031.desc_dead
			}
		}
	}
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_coward
	}
	right_portrait = scope:prev_soulmate

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			has_inspiration_type = book_inspiration
			inspiration_owner = {
				exists = var:book_subject
				var:book_subject = flag:relationship
				exists = var:book_topic
				var:book_topic = flag:soulmate
				exists = var:book_topic_relationship
				var:book_topic_relationship = {
					NOT = { has_relation_soulmate = root } #You're no longer soulmates :(
				}
				NOT = { has_character_flag = had_event_fund_inspiration_3031 }
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_3031
				years = 20
			}
		}
		scope:inspiration_owner.var:book_topic_relationship = {
			save_scope_as = prev_soulmate
		}
	}

	# Continue writing
	option = {
		name = fund_inspiration.3031.a
		custom_tooltip = fund_inspiration.3031.a.tt
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = 4
			}
		}
		add_stress = medium_stress_gain
		ai_chance = {
			base = 0
		}
	}

	# Scrap it
	option = {
		name = fund_inspiration.3031.b
		end_inspiration_sponsorship = scope:inspiration
		#Let them start over
		inspiration_completion_effect = yes
		ai_chance = {
			base = 100
		}
	}
}

# Weaver - Weaver is stealing clothes
# by Linnéa Thimrén
scripted_trigger fund_inspiration_4001_courtier_trigger = {
	is_available_ai_adult = yes
	NOT = { this = scope:inspiration_owner }
}

fund_inspiration.4001 = {
	type = character_event
	title = fund_inspiration.4001.t
	desc = fund_inspiration.4001.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = dismissal
	}
	right_portrait = {
		character = scope:courtier
		animation = anger
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			has_inspiration_type = weaver_inspiration
			inspiration_owner = {
				is_available_ai_adult = yes
				has_no_inspiration_event_cooldown = yes
				NOR = {
					has_character_flag = had_event_fund_inspiration_4001
					has_variable = banner_commission
				}
			}
		}
		any_courtier = {
			fund_inspiration_4001_courtier_trigger = yes
		}
		
		NOT = {
			government_has_flag = government_is_tribal # No changing amenities above what's legal for tribals
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_4001
				years = 20
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_weaver_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		random_courtier = {
			limit = {
				fund_inspiration_4001_courtier_trigger = yes
			}
			save_scope_as = courtier
		}
	}

	#Chastise them
	option = {
		name = fund_inspiration.4001.a
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -15
			}
		}
		scope:courtier = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
			}
		}
	}

	#Approve
	option = {
		name = fund_inspiration.4001.b
		# Lower fashion one step
		if = {
			limit = {
				amenity_level = { type = court_fashion value = max_amenity_level }
			}
			set_amenity_level = { type = court_fashion value = very_high_amenity_level }
		}
		else_if = {
			limit = {
				amenity_level = { type = court_fashion value = very_high_amenity_level }
			}
			set_amenity_level = { type = court_fashion value = high_amenity_level }
		}
		else_if = {
			limit = {
				amenity_level = { type = court_fashion value = high_amenity_level }
			}
			set_amenity_level = { type = court_fashion value = medium_amenity_level }
		}
		else_if = {
			limit = {
				amenity_level = { type = court_fashion value = medium_amenity_level }
			}
			set_amenity_level = { type = court_fashion value = low_amenity_level }
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = { AMOUNT = 4 }
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 15
			}
		}
		scope:courtier = {
			add_opinion = {
				target = root
				modifier = dismissive_opinion
				opinion = -20
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_compassion = -0.5
			}
		}
	}
}


# Adventurer - Choose your item-type
# By Bianca Savazzi and Linnéa Thimrén
fund_inspiration.5011 = {
	type = character_event
	title = fund_inspiration.0001.t
	desc = fund_inspiration.5011.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			is_physically_able_ai_adult = yes
			has_no_inspiration_event_cooldown = yes
			NOR = {
				exists = var:adventure_type
				has_character_flag = had_event_fund_inspiration_5011
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		#Saving some scopes for the tooltips

		save_scope_as = actor
		scope:inspiration_owner = {
			assign_quirk_effect = yes
			save_scope_as = recipient
			add_character_flag = {
				flag = had_event_fund_inspiration_5011
				years = 20
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_adventure_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		show_as_tooltip = {
			fund_inspiration_effect = yes
		}
	}

	# Go find an epic artifact!
	option = {
		name = fund_inspiration.5011.e
		trigger = {
			scope:inspiration_owner = {
				adventure_inspiration_average_skill_value >= medium_inspiration_skill
			}
		}
		scope:inspiration_owner = { 
			set_variable = {
				name = adventure_type
				value = flag:epic_quest
			}
		}

		ai_chance = {
			base = 50
			modifier = {
				add = 25
				OR = {
					has_trait = ambitious
					has_trait = adventurer
				}
			}
		}
	}

	# skull or hide
	option = {
		name = fund_inspiration.5011.a
		scope:inspiration_owner = {
			set_variable = {
				name = adventure_type
				value = flag:skull_or_hide
			}
		}

		ai_chance = {
			base = 50
			modifier = {
				add = 25
				has_trait = vengeful
			}
			modifier = {
				add = 25
				OR = {
					has_martial_lifestyle_trait_trigger = yes
 					has_lifestyle = martial_lifestyle
 				}
			}
		}
	}

	# trinket
	option = {
		name = fund_inspiration.5011.b

		scope:inspiration_owner = { 
			set_variable = {
				name = adventure_type
				value = flag:trinket
			}
		}

		ai_chance = {
			base = 25
			modifier = {
				add = 25
				has_trait = greedy
			}
			modifier = {
				add = 25
				OR = {
					has_stewardship_lifestyle_trait_trigger = yes
 					has_lifestyle = stewardship_lifestyle
 				}
			}
			modifier = {
				factor = 0
				OR = {
					any_character_artifact = { # Has a fantastic item already
						artifact_slot_type = miscellaneous
						rarity = illustrious
					}
					AND = { # Have a lot of artifacts already, and the inspired person isn't even very good
						scope:inspiration_owner = {
							smith_inspiration_average_skill_value < high_inspiration_skill
						}
						any_character_artifact = {
							count >= 4
							artifact_slot_type = miscellaneous
						}
					}
				}
			}
		}
	}

	# tapestry or fabric
	option = {
		name = fund_inspiration.5011.c

		scope:inspiration_owner = { 
			set_variable = {
				name = adventure_type
				value = flag:tapestry_or_fabric
			}
		}

		ai_chance = {
			base = 25
			modifier = {
				add = 25
				has_focus_learning = yes
			}
			modifier = {
				add = 25
				OR = {
					has_learning_lifestyle_trait_trigger = yes
 					has_lifestyle = learning_lifestyle
 				}
			}
		}
	}

	# default option of "do what you want"
	option = {
		name = fund_inspiration.5011.d

		scope:inspiration_owner = { 
			set_variable = {
				name = adventure_type
				value = flag:free_reign
			}
		}

		ai_chance = {
			base = 5
			modifier = {
				add = 25
				OR = {
					has_trait = arbitrary
					has_trait = lazy
				}
			}
		}
	}

	after = {
		#To start the adventure for the inspiration owner
		fund_adventure_inspiration_start_effect = { ADVENTURER = scope:inspiration_owner }
	}
}

#Adventurer gets lost... this can be a good thing though
fund_inspiration.5021 = {
	type = character_event
	title = fund_inspiration.5021.t
	desc = fund_inspiration.5021.desc
	theme = realm

	left_portrait = {
		character = scope:adventurer_aide
		animation = beg
	}

	right_portrait = {
		character = scope:inspiration_owner
		animation = happiness 
	}
	cooldown = { years = 15 }

	trigger = {
		exists = scope:inspiration
		scope:inspiration_owner = {
			exists = var:adventure_destination
			exists = var:adventure_type
			has_no_inspiration_event_cooldown = yes
			NOT = { has_character_flag = had_event_fund_inspiration_5021 }
			adventure_inspiration_average_skill_value < high_inspiration_skill
		}
	}

	weight_multiplier = {
		base = 1
		# More likely to happen if the adventurer is adventurous, and maybe a bit scatterbrained 
		modifier = {
			add = 2
			scope:inspiration_owner = {
				has_trait = fickle
			}
		}
		modifier = {
			add = 2
			scope:inspiration_owner = {
				has_trait = adventurer
			}
		}
		modifier = {
			add = 2
			scope:inspiration_owner = {
				has_trait = brave
			}
		}
		modifier = {
			add = 2
			scope:inspiration_owner = {
				has_trait = stubborn #refusing to ask for direction
			}
		}
		modifier = {
			add = -1
			scope:inspiration_owner = {
				adventure_inspiration_average_skill_value >= high_inspiration_skill
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_5021
				years = 20
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_adventure_inspiration_event_cooldown
				days = { 30 60 }
			}
		}

		#Prioritize location that root doesn't have a county in 
		hidden_effect = {
			random_list = {
				1 = {
					# Kinai
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_kinai
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_kinai
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:kinai }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_kinai
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_kinai
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_kinai_location
						value = yes
					}
				}
				1 = {
					# Tokaido
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_tokaido
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_tokaido
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:tokaido }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_tokaido
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_tokaido
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_tokaido_location
						value = yes
					}
				}
				1 = {
					# Tosando
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_tosando
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_tosando
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:tosando }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_tosando
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_tosando
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_tosando_location
						value = yes
					}
				}
				1 = {
					# Hokurikudo
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_hokurikudo
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_hokurikudo
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:hokurikudo }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_hokurikudo
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_hokurikudo
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_hokurikudo_location
						value = yes
					}
				}
				1 = {
					# Sanindo
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_san'indo
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_san'indo
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:sanindo }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_san'indo
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_san'indo
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_sanindo_location
						value = yes
					}
				}
				1 = {
					# Sanyodo
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_san'yodo
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_san'yodo
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:sanyodo }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_san'yodo
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_san'yodo
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_sanyodo_location
						value = yes
					}
				}
				1 = {
					# Nankaido
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_nankaido
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_nankaido
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:nankaido }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_nankaido
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_nankaido
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_nankaido_location
						value = yes
					}
				}
				1 = {
					# Saikaido
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_saikaido
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_saikaido
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:saikaido }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_saikaido
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_saikaido
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_saikaido_location
						value = yes
					}
				}
				1 = {
					# Hokkaido
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_hokkaido
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_hokkaido
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:hokkaido }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_hokkaido
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_hokkaido
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_hokkaido_location
						value = yes
					}
				}
				1 = {
					# Karafuto
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_karafuto
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_karafuto
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:karafuto }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_karafuto
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_karafuto
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_karafuto_location
						value = yes
					}
				}
				1 = {
					# Ryukyu
					trigger = {
	  					#There's a county you don't hold there
	  					any_county_in_region = {
							region = world_circuit_ryukyu
							NOT = { holder = root }
						}
						scope:inspiration_owner = { #Distance check - from where the adventurer is right now.
							adventurer_potential_destination_distance_check = {
								REGION = world_circuit_ryukyu
							}
						}
						#This was not the original destination of the adventurer
	  					NOT = { scope:inspiration_owner.var:adventure_destination = flag:ryukyu }
					}
					modifier = {
						add = 30
						NOT = {
							any_county_in_region = {
								region = world_circuit_ryukyu
								holder = root 
								count >= 1
							}
						}
					}
					random_county_in_region = {
						region = world_circuit_ryukyu
						limit = { 
							NOT = { holder = root }
						}
						save_scope_as = adventuring_location
					}
					save_scope_value_as = {
						name = world_circuit_ryukyu_location
						value = yes
					}
				}
			}

			if = {
				limit = { exists = scope:adventuring_location }
				create_character = {
					location = root.location
					template = hunter_template
					culture = scope:adventuring_location.culture
					faith = scope:adventuring_location.faith
					dynasty = none
					save_scope_as = adventurer_aide
				}
			}
			else = { # Fallback in case that a region could not be selected for some reason, purely theoretical fix
				create_character = {
					location = root.location
					template = hunter_template
					culture = root.culture
					faith = root.faith
					dynasty = none
					save_scope_as = adventurer_aide
				}
				debug_log = "WARNING: create_character fallback triggered in ep1 fund_inspiration.5021, something went wrong!"
			}
		}
	}

	#No, go back!
	option = { 
		name = fund_inspiration.5021.a
		custom_tooltip = fund_inspiration.5021.a.tt
		scope:inspiration_owner = { 
			add_opinion = {
				modifier = disappointed_opinion
				target = root
				opinion = -25
			}
		}

		ai_chance = {
			base = 10
			ai_greed_target_modifier = { VALUE = 25 } #not too high since there's a chance to get a cooler artifact
		}
	}

	#Explore!
	option = {
		name = fund_inspiration.5021.b
		custom_tooltip = fund_inspiration.5021.b.tt
		scope:inspiration = {
			invest_gold = 60
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = 4
			}
		}
		scope:inspiration_owner = { 
			add_opinion = {
				modifier = pleased_opinion
				target = root
				opinion = 25
			}
			if = {
				limit = {
					exists = scope:world_circuit_kinai_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:kinai
				}
			}
			else_if = {
				limit = {
					exists = scope:world_circuit_tokaido_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:tokaido
				}
			}
			else_if = {
				limit = {
					exists = scope:world_circuit_tosando_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:tosando
				}
			}
			else_if = {
				limit = {
					exists = scope:world_circuit_hokurikudo_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:hokurikudo
				}
			}
			else_if = {
				limit = {
					exists = scope:world_circuit_sanindo_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:sanindo
				}
			}
			else_if = {
				limit = {
					exists = scope:world_circuit_sanyodo_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:sanyodo
				}
			}
			else_if = {
				limit = {
					exists = scope:world_circuit_nankaido_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:nankaido
				}
			}
			else_if = {
				limit = {
					exists = scope:world_circuit_saikaido_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:saikaido
				}
			}
			else_if = {
				limit = {
					exists = scope:world_circuit_hokkaido_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:hokkaido
				}
			}
			else_if = {
				limit = {
					exists = scope:world_circuit_karafuto_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:karafuto
				}
			}
			else_if = {
				limit = {
					exists = scope:world_circuit_ryukyu_location
				}
				set_variable = {
					name = adventure_destination
					value = flag:ryukyu
				}
			}
			hidden_effect = {
				scope:inspiration_owner = {
					set_location = {
						location = scope:adventuring_location.title_province
						stick_to_location = yes 
					}
				}
			}
		}

		ai_chance = {
			base = 10
			ai_boldness_target_modifier = { VALUE = 100 }
			modifier = {
				short_term_gold < 60 #shouldn't spend money they don't have...
				factor = 0
			}
		}
	}

	after = {
		scope:adventurer_aide = {
			silent_disappearance_effect = yes
		}
	}
}

# Postcard from your adventurer 6001-6006!

# Postcard from the Steppe

fund_inspiration.6001 = {
	type = letter_event
	opening = { desc = fund_inspiration.6001.t }
	desc = fund_inspiration.6001.desc
	sender = scope:inspiration_owner
	
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		location = {#We can't have an adventurer writing home about what a region is like that we belong to
			NOT = {
				geographical_region = world_steppe
			}
		}
		NOT = {
			any_character_artifact = {
				has_variable = morin_khuur_ornament
			}
		}
		is_ai = no
		scope:inspiration_owner = {
			exists = var:adventure_destination
			exists = var:adventure_type
			NOT = {  has_character_flag = had_event_fund_inspiration_6001 }
			has_no_inspiration_event_cooldown = yes
			OR = {
				var:adventure_destination = flag:steppe
				var:adventure_destination = flag:steppe_east
				var:adventure_destination = flag:steppe_west
			}
			NOT = {
				any_character_artifact = {
					has_variable = morin_khuur_ornament
				}
			}
		}
	}

	immediate = {
		save_scope_as = owner #for loc
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_6001
				years = 5
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_adventure_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		create_artifact = {
			name = morin_khuur_ornament_name
			description = morin_khuur_ornament_description
			type = miscellaneous
			visuals = medallion
			modifier = artifact_heavy_cavalry_toughness_1_modifier
			creator = scope:inspiration_owner
			save_scope_as = morin_khuur_ornament
			history = {
				type = discovered
				actor = scope:inspiration_owner
				recipient = root
				location = scope:inspiration_owner.location
			}
		}
		hidden_effect_new_object = {
			scope:morin_khuur_ornament = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = morin_khuur_ornament
					value = yes
				}
			}
		}
	}
	#Keep the fiddle-head for yourself
	option = {
		name = fund_inspiration.6001.a
		ai_chance = {
			base = 50
		}
	}
	#If the court musician is present, let them have this former piece of an instrument
	option = {
		name = fund_inspiration.6001.b
		trigger = {
			any_court_position_holder = {
				has_court_position = court_musician_court_position
			}
		}
		random_court_position_holder = {
			limit = {
				has_court_position = court_musician_court_position
			}
			save_scope_as = court_musician
		}
		scope:morin_khuur_ornament = {
			set_owner = scope:court_musician
		}
		reverse_add_opinion = {
			target = scope:court_musician
			modifier = grateful_opinion
			opinion = 15
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = -0.5
			}
		}
	}
}

#Postcard from India

fund_inspiration.6002 = {
	type = letter_event
	opening = { desc = fund_inspiration.6002.t }
	desc = fund_inspiration.6002.desc
	sender = scope:inspiration_owner
	
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		location = {#We can't have an adventurer writing home about what a region is like that we belong to
			NOT = {
				geographical_region = world_india
			}
		}
		NOT = {
			any_character_artifact = {
				has_variable = animal_ring
			}
		}
		is_ai = no
		scope:inspiration_owner = {
			exists = var:adventure_destination
			exists = var:adventure_type
			NOT = {  has_character_flag = had_event_fund_inspiration_6002 }
			has_no_inspiration_event_cooldown = yes
			OR = {
				var:adventure_destination = flag:india
				var:adventure_destination = flag:india_deccan
				var:adventure_destination = flag:india_bengal
				var:adventure_destination = flag:india_rajastan
			}
			NOT = {
				any_character_artifact = {
					has_variable = animal_ring
				}
			}
		}
	}

	immediate = {
		save_scope_as = owner #for loc
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_6002
				years = 5
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_adventure_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		create_artifact = {
			name = animal_ring_name
			description = animal_ring_description
			type = miscellaneous
			visuals = ring
			modifier = artifact_scheme_resistance_add_2_modifier
			creator = scope:inspiration_owner
			save_scope_as = animal_ring
			history = {
				type = discovered
				actor = scope:inspiration_owner
				recipient = root
				location = scope:inspiration_owner.location
			}
		}
		hidden_effect_new_object = {
			scope:animal_ring = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = animal_ring
					value = yes
				}
			}
		}
	}
	#Keep the ring
	option = {
		name = fund_inspiration.6002.a
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 0.5
			}
		}
	}
	#Sell the ring for gold
	option = {
		name = fund_inspiration.6002.b
		destroy_artifact = scope:animal_ring
		add_gold = minor_gold_value
		ai_chance = {
			base = 200
			ai_value_modifier = {
				ai_honor = -0.5
				ai_greed = 0.5
			}
		}
	}
}

#Postcard from Africa

fund_inspiration.6003 = {
	type = letter_event
	opening = { desc = fund_inspiration.6003.t }
	desc = fund_inspiration.6003.desc
	sender = scope:inspiration_owner
	
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		location = {#We can't have an adventurer writing home about what a region is like that we belong to
			NOT = {
				geographical_region = world_africa
			}
		}
		NOT = {
			any_character_artifact = {
				has_variable = ostrich_shell_necklace
			}
		}
		is_ai = no
		scope:inspiration_owner = {
			exists = var:adventure_destination
			exists = var:adventure_type
			NOT = {  has_character_flag = had_event_fund_inspiration_6003 }
			has_no_inspiration_event_cooldown = yes
			OR = {
				var:adventure_destination = flag:africa
				var:adventure_destination = flag:africa_north
				var:adventure_destination = flag:africa_west
			}
			NOT = {
				any_character_artifact = {
					has_variable = ostrich_shell_necklace
				}
			}
		}
	}

	immediate = {
		save_scope_as = owner #for loc
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_6003
				years = 5
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_adventure_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		create_artifact = {
			name = ostrich_shell_necklace_name
			description = ostrich_shell_necklace_description
			type = miscellaneous
			visuals = necklace
			modifier = artifact_attraction_opinion_2_modifier
			creator = scope:inspiration_owner
			save_scope_as = ostrich_shell_necklace
			history = {
				type = discovered
				actor = scope:inspiration_owner
				recipient = root
				location = scope:inspiration_owner.location
			}
		}
		hidden_effect = {
			scope:ostrich_shell_necklace = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = ostrich_shell_necklace
					value = yes
				}
			}
		}
		if = {
			limit = { is_married = yes }
			random_spouse = { save_scope_as = event_spouse }
		}
	}
	option = {
		name = fund_inspiration.6003.a
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = -0.5
			}
		}
	}
	option = {
		name = fund_inspiration.6003.b
		trigger = { exists = scope:event_spouse }
		reverse_add_opinion = {
			target = scope:event_spouse
			modifier = grateful_opinion
			opinion = 15
		}
		scope:ostrich_shell_necklace = {
			set_owner = scope:event_spouse
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_honor = 0.5
			}
		}
	}
}

# Postcard from the Middle East

fund_inspiration.6004 = {
	type = letter_event
	opening = { desc = fund_inspiration.6004.t }
	desc = fund_inspiration.6004.desc
	sender = scope:inspiration_owner
	
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		NOT = {
			any_character_artifact = {
				has_variable = pilgrimage_figurine
			}
		}
		location = {#We can't have an adventurer writing home about what a region is like that we belong to
			NOR = {
				geographical_region = world_middle_east
				geographical_region = world_middle_east_jerusalem
				geographical_region = world_middle_east_persia
			}
		}
		is_ai = no
		scope:inspiration_owner = {
			exists = var:adventure_destination
			exists = var:adventure_type
			NOT = {  has_character_flag = had_event_fund_inspiration_6004 }
			has_no_inspiration_event_cooldown = yes
			OR = {
				var:adventure_destination = flag:middle_east
				var:adventure_destination = flag:middle_east_jerusalem
				var:adventure_destination = flag:middle_east_persia
			}
			NOT = {
				any_character_artifact = {
					has_variable = pilgrimage_figurine
				}
			}
		}
	}

	immediate = {
		save_scope_as = owner #for loc
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_6004
				years = 5
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_adventure_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		create_artifact = {
			name = pilgrimage_figurine_name
			description = pilgrimage_figurine_description
			type = miscellaneous
			visuals = pouch
			modifier = artifact_knight_limit_1_modifier
			creator = scope:inspiration_owner
			save_scope_as = pilgrimage_figurine
			history = {
				type = discovered
				actor = scope:inspiration_owner
				recipient = root
				location = scope:inspiration_owner.location
			}
		}
		hidden_effect_new_object = {
			scope:pilgrimage_figurine = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = pilgrimage_figurine
					value = yes
				}
			}
		}
	}

	option = {
		name = fund_inspiration.6004.a
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}
}

#Postcard from Europe

fund_inspiration.6005 = {
	type = letter_event
	opening = { desc = fund_inspiration.6005.t }
	desc = fund_inspiration.6005.desc
	sender = scope:inspiration_owner
	
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		NOT = {
			any_character_artifact = {
				has_variable = saint_margaret_fingernails
			}
		}
		is_ai = no
		NOT = {
			location = {
				geographical_region = world_europe #We can't have an adventurer writing home about what Europeans are like if you are also a European.
			}
		}
		scope:inspiration_owner = {
			exists = var:adventure_destination
			exists = var:adventure_type
			NOT = {  has_character_flag = had_event_fund_inspiration_6005 }
			has_no_inspiration_event_cooldown = yes
			OR = {
				var:adventure_destination = flag:europe
				var:adventure_destination = flag:europe_east
				var:adventure_destination = flag:europe_west
				var:adventure_destination = flag:europe_north
				var:adventure_destination = flag:europe_south
			}
			NOT = {
				any_character_artifact = {
					has_variable = saint_margaret_fingernails
				}
			}
		}
	}

	immediate = {
		save_scope_as = owner #for loc
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_6005
				years = 5
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_adventure_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		create_artifact = {
			name = saint_margaret_fingernails_name
			description = saint_margaret_fingernails_description
			type = pedestal
			visuals = reliquary
			modifier = artifact_prowess_1_modifier
			creator = scope:inspiration_owner
			save_scope_as = saint_margaret_fingernails
			history = {
				type = discovered
				actor = scope:inspiration_owner
				recipient = root
				location = scope:inspiration_owner.location
			}
		}
		hidden_effect_new_object = {
			scope:saint_margaret_fingernails = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = saint_margaret_fingernails
					value = yes
				}
			}
		}
	}

	option = {
		name = fund_inspiration.6005.a
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = disappointed_opinion
			opinion = -30
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_compassion = -0.5
			}
		}
	}
	option = {
		name = fund_inspiration.6005.b
		custom_tooltip = fund_inspiration.6005.b.tt
		scope:inspiration_owner = {
			add_character_flag = adventurer_tired_of_europe
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_compassion = 0.5
			}
		}
	}
}

# Postcard from Asia Minor

fund_inspiration.6006 = {
	type = letter_event
	opening = { desc = fund_inspiration.6006.t }
	desc = fund_inspiration.6006.desc
	sender = scope:inspiration_owner
	
	cooldown = { years = 5 }

	trigger = {
		exists = scope:inspiration
		location = {#We can't have an adventurer writing home about what a region is like that we belong to
			NOT = {
				geographical_region = world_asia_minor
			}
		}
		NOT = {
			any_character_artifact = {
				has_variable = seahorse_brooch
			}
		}
		is_ai = no
		scope:inspiration_owner = {
			exists = var:adventure_destination
			exists = var:adventure_type
			NOT = {  has_character_flag = had_event_fund_inspiration_6006 }
			has_no_inspiration_event_cooldown = yes
			var:adventure_destination = flag:asia_minor
			NOT = {
				any_character_artifact = {
					has_variable = seahorse_brooch
				}
			}
		}
	}

	immediate = {
		save_scope_as = owner #for loc
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_6006
				years = 5
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_adventure_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		create_artifact = {
			name = seahorse_brooch_name
			description = seahorse_brooch_description
			type = miscellaneous
			visuals = brooch
			modifier = artifact_tolerance_advantage_mod_1_modifier
			creator = scope:inspiration_owner
			save_scope_as = seahorse_brooch
			history = {
				type = discovered
				actor = scope:inspiration_owner
				recipient = root
				location = scope:inspiration_owner.location
			}
		}
		hidden_effect = {
			scope:seahorse_brooch = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = seahorse_brooch
					value = yes
				}
			}
		}
	}
	option = {
		name = fund_inspiration.6006.a
		trigger = {
			NOT = { government_has_flag = government_is_tribal }
		}
		if = {
			limit = {
				amenity_level = { 
					type = court_food_quality
					value < medium_amenity_level
				}
			}
			set_amenity_level = { type = court_food_quality value = 3 }
		}
		else_if = {
			limit = {
				amenity_level = { 
					type = court_food_quality
					value < high_amenity_level
				}
			}
			set_amenity_level = { type = court_food_quality value = 4 }
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = 0.5
				ai_compassion = 0.5
			}
		}
	}
	option = {
		name = fund_inspiration.6006.b
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_vengefulness = 0.5
			}
		}
	}
}



# Tiny chest miniature

fund_inspiration.6100 = {
	type = character_event
	title = fund_inspiration.6100.t
	desc = fund_inspiration.6100.desc
	theme = realm

	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = worry
	}

	right_portrait = { 
		character = root
		animation = personality_bold
	}
	
	cooldown = { years = 5 }

	trigger = {
		scope:inspiration_owner = {
			exists = var:artifact_artisan_type
			var:artifact_artisan_type = flag:artisan_type_chest
		}
		NOT = {
			# Don't get it twice
			any_character_artifact = {
				exists = var:miniature_collection_tiny_chest
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			create_artifact = {
				name = tiny_chest_trinket_name
				description = tiny_chest_trinket_description
				type = miscellaneous
				visuals = chest
				modifier = artifact_build_time_1_modifier
				save_scope_as = tiny_chest_trinket
				template = child_toy_template
			}
		}
		hidden_effect_new_object = {
			scope:tiny_chest_trinket = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = miniature_collection_tiny_chest
				}
			}
		}
	}

	option = { 
		name = fund_inspiration.6100.a
		add_gold = minor_gold_value
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = cruelty_opinion
			opinion = -10
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6100.b
		scope:tiny_chest_trinket = {
			set_owner = root
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = respect_opinion
			opinion = 10
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_greed = -0.5
			}
		}
	}
}

#Tiny box miniature

fund_inspiration.6101 = {
	type = character_event
	title = fund_inspiration.6100.t
	desc = fund_inspiration.6101.desc
	theme = realm

	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	right_portrait = { 
		character = root
		animation = happiness
	}
	
	cooldown = { years = 5 }

	trigger = {
		scope:inspiration_owner = {
			exists = var:artifact_artisan_type
			var:artifact_artisan_type = flag:artisan_type_box
		}
		NOT = {
			# Don't get it twice
			any_character_artifact = {
				exists = var:miniature_collection_tiny_box
			}
		}
		any_court_position_holder = {
			has_court_position = antiquarian_court_position
			is_available_ai_adult = yes
		}
	}

	immediate = {
		scope:inspiration_owner = {
			create_artifact = {
				name = tiny_box_trinket_name
				description = tiny_box_trinket_description
				type = miscellaneous
				visuals = small_box
				modifier = artifact_monthly_stewardship_lifestyle_xp_1_modifier
				save_scope_as = tiny_box_trinket
				template = child_toy_template
			}
		}
		hidden_effect_new_object = {
			scope:tiny_box_trinket = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = miniature_collection_tiny_box
				}
			}
		}
		random_court_position_holder = {
			limit = {
				has_court_position = antiquarian_court_position
				is_available_ai_adult = yes
			}
			save_scope_as = antiquarian
		}
	}

	option = { 
		name = fund_inspiration.6101.a
		add_diplomacy_lifestyle_xp = medium_lifestyle_xp
		root.dynasty ?= {
			add_dynasty_prestige = miniscule_dynasty_prestige_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6101.b
		add_learning_lifestyle_xp = medium_lifestyle_xp
		if = {
			limit = { NOT = { has_trait = poet } }
			add_trait = poet
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = -0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6101.c
		scope:tiny_box_trinket = {
			set_owner = root
		}
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			change_current_court_grandeur = minor_court_grandeur_gain
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_greed = 0.5
			}
		}
	}
}


#Tiny sculpture miniature

fund_inspiration.6102 = {
	type = character_event
	title = fund_inspiration.6100.t
	desc = fund_inspiration.6102.desc
	theme = realm

	override_background = {
		reference = corridor_night
	}
	left_portrait = {
		character = scope:inspiration_owner
		animation = schadenfreude
	}

	right_portrait = { 
		character = root
		animation = pain
	}
	
	cooldown = { years = 5 }

	trigger = {
		scope:inspiration_owner = {
			exists = var:artifact_artisan_type
			var:artifact_artisan_type = flag:artisan_type_sculpture
		}
		NOT = {
			# Don't get it twice
			any_character_artifact = {
				exists = var:miniature_collection_tiny_sculpture
			}
		}
	}

	immediate = {
		save_scope_as = statue_owner
		scope:inspiration_owner = {
			create_artifact = {
				name = tiny_sculpture_trinket_name
				description = tiny_sculpture_trinket_description
				type = miscellaneous
				visuals = pocket_figurine
				modifier = artifact_dynasty_opinion_1_modifier
				save_scope_as = tiny_sculpture_trinket
				template = child_toy_template
			}
		}
		hidden_effect_new_object = {
			scope:tiny_sculpture_trinket = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = miniature_collection_tiny_sculpture
				}
			}
		}
		increase_wounds_effect = { REASON = miniatures }
	}

	option = {
		name = fund_inspiration.6102.a
		scope:inspiration_owner = {
			save_scope_as = physician
		}
		random_list = {
			50 = {
				modifier = {
					factor = scope:inspiration_owner.learning
				}
				wound_treatment_results_effect = { TREATMENT = safe OUTCOME = success }
				hidden_effect = {
					send_interface_toast = {
						left_icon = root
						title = fund_inspiration.6102.cure_toast

						show_as_tooltip = {
							wound_treatment_results_effect = { TREATMENT = safe OUTCOME = success }
						}
					}
				}
			}
			50 = {
				increase_wounds_effect = { REASON = miniatures }
				hidden_effect = {
					destroy_artifact = scope:tiny_sculpture_trinket
					send_interface_toast = {
						left_icon = root
						title = fund_inspiration.6102.failure_toast
						custom_tooltip = fund_inspiration.6102.failure_toast_desc
					}
				}
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6102.b
		trigger = { court_physician_available_trigger = yes }
		save_court_physician_as_effect = { SCOPE_NAME = physician }
		random_list = {
			25 = {
				modifier = {
					factor = scope:physician.physician_safe_treatment_skill_factor
				}
				wound_treatment_results_effect = { TREATMENT = safe OUTCOME = success }
				hidden_effect = {
					send_interface_toast = {
						left_icon = root
						title = fund_inspiration.6102.cure_toast

						show_as_tooltip = {
							wound_treatment_results_effect = { TREATMENT = safe OUTCOME = success }
						}
					}
				}
			}
			50 = {
				hidden_effect = {
					destroy_artifact = scope:tiny_sculpture_trinket
					send_interface_toast = {
						left_icon = root
						title = fund_inspiration.6102.failure_toast
						custom_tooltip = fund_inspiration.6102.failure_toast_desc
					}
				}
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6102.c
		save_scope_as = physician
		random_list = {
			25 = {
				modifier = {
					factor = root.learning
				}
				wound_treatment_results_effect = { TREATMENT = safe OUTCOME = success }
				hidden_effect = {
					send_interface_toast = {
						left_icon = root
						title = fund_inspiration.6102.cure_toast

						show_as_tooltip = {
							wound_treatment_results_effect = { TREATMENT = safe OUTCOME = success }
						}
						scope:tiny_sculpture_trinket = {
							set_owner = root
						}
					}
				}
			}
			50 = {
				increase_wounds_effect = { REASON = miniatures }
				hidden_effect = {
					destroy_artifact = scope:tiny_sculpture_trinket
					send_interface_toast = {
						left_icon = root
						title = fund_inspiration.6102.failure_toast
						custom_tooltip = fund_inspiration.6102.failure_toast_desc
					}
				}
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
	}
}

# Tiny cabinet miniature

fund_inspiration.6103 = {
	type = character_event
	title = fund_inspiration.6100.t
	desc = fund_inspiration.6103.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = happiness
	}

	right_portrait = { 
		character = root
		animation = boredom
	}
	
	cooldown = { years = 5 }

	trigger = {
		scope:inspiration_owner = {
			exists = var:artifact_artisan_type
			var:artifact_artisan_type = flag:artisan_type_cabinet
			#Mena and Indian cabinets are tables and diwans!
			NOR = {
				artifact_use_indian_building_visuals_trigger = yes
				artifact_use_mena_building_visuals_trigger = yes
			}
		}
		NOT = {
			# Don't get it twice
			any_character_artifact = {
				exists = var:miniature_collection_tiny_cabinet
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			create_artifact = {
				name = tiny_cabinet_trinket_name
				description = tiny_cabinet_trinket_description
				type = miscellaneous
				visuals = cabinet_trinket
				modifier = artifact_build_time_2_modifier
				save_scope_as = tiny_cabinet_trinket
				template = child_toy_template
			}
		}
		hidden_effect_new_object = {
			scope:tiny_cabinet_trinket = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = miniature_collection_tiny_cabinet
				}
			}
		}
	}

	option = { 
		name = fund_inspiration.6103.a
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = respect_opinion
			opinion = 10
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_vengefulness = 0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6103.b
		end_inspiration_sponsorship = scope:inspiration
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = respect_opinion
			opinion = 10
		}
		scope:tiny_cabinet_trinket = {
			set_owner = root
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
	}
}



#Tiny throne miniature

fund_inspiration.6104 = {
	type = character_event
	title = fund_inspiration.6100.t
	desc = fund_inspiration.6104.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}

	right_portrait = { 
		character = root
		animation = happiness
	}
	
	cooldown = { years = 5 }

	trigger = {
		scope:inspiration_owner = {
			exists = var:artifact_artisan_type
			var:artifact_artisan_type = flag:artisan_type_throne
		}
		NOT = {
			# Don't get it twice
			any_character_artifact = {
				exists = var:miniature_collection_tiny_throne
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			create_artifact = {
				name = tiny_throne_trinket_name
				description = tiny_throne_trinket_description
				type = miscellaneous
				visuals = tiny_throne_trinket
				modifier = artifact_child_opinion_2_modifier
				save_scope_as = tiny_throne_trinket
				template = child_toy_template
			}
		}
		hidden_effect_new_object = {
			scope:tiny_throne_trinket = {
				flag_as_trash_artifact = yes
				set_variable = {
					name = miniature_collection_tiny_throne
				}
			}
		}
	}

	option = { 
		name = fund_inspiration.6104.a
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = respect_opinion
			opinion = 10
		}
		scope:tiny_throne_trinket = {
			set_owner = root
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6104.b
		trigger = {
			OR = {
				age < 5
				age > 18
			}
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = dismissive_opinion
			opinion = -10
		}
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			change_current_court_grandeur = minor_court_grandeur_gain
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6104.c
		trigger = {
			age > 5
			age < 18
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = dismissive_opinion
			opinion = -10
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}
}


#Ruler collected all the miniatures!

fund_inspiration.6105 = {
	type = character_event
	title = fund_inspiration.6100.t
	desc = fund_inspiration.6105.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_honorable
	}
	right_portrait = { 
		character = root
		animation = happiness
	}
	override_background = {
		reference = corridor_day
	}
	trigger = {
		AND = {
			any_character_artifact = {
				exists = var:miniature_collection_tiny_chest
			}
			any_character_artifact = {
				exists = var:miniature_collection_tiny_sculpture
			}
			any_character_artifact = {
				exists = var:miniature_collection_tiny_cabinet
			}
			any_character_artifact = {
				exists = var:miniature_collection_tiny_throne
			}
			any_character_artifact = {
				exists = var:miniature_collection_tiny_box
			}
		}
		NOT = { has_character_flag = has_had_fund_inspiration_6105_miniatures_event }
	}

	immediate = {
		add_character_flag = has_had_fund_inspiration_6105_miniatures_event
	}

	option = { 
		name = fund_inspiration.6105.a
		progress_towards_friend_effect = {
			CHARACTER = scope:inspiration_owner
			OPINION = default_friend_opinion
			REASON = friend_miniature_game
		}
		add_character_modifier = {
			modifier = playing_with_miniatures
			years = 5
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6105.b
		add_prestige = minor_prestige_gain
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = dismissive_opinion
			opinion = -10
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}
}

# Weaver is too much of a modernist

scripted_trigger artistic_courtier_trigger = {
	is_available_ai_adult = yes
	is_courtier_of = root
}

fund_inspiration.6200 = {
	type = character_event
	title = fund_inspiration.6200.t
	desc = fund_inspiration.6200.desc
	theme = realm

	left_portrait = { 
		character = scope:artistic_courtier_1
		animation = happiness
	}

	right_portrait = { 
		character = scope:artistic_courtier_2
		animation = scheme
	}
	cooldown = { years = 5 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = weaver_inspiration
			inspiration_owner = { #They know what tapestry they want to make 
				exists = var:artifact_tapestry_scene
				var:artifact_tapestry_scene = flag:geometric_patterns
			}
		}
		any_courtier_or_guest = {
			artistic_courtier_trigger = yes
			count >= 2	
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		random_courtier = {
			limit = { artistic_courtier_trigger = yes }
			weight = {
				base = 1
				modifier = {
					factor = 10
					learning > high_skill_rating
				}
			}
			save_scope_as = artistic_courtier_1
		}
		random_courtier = {
			limit = {
				artistic_courtier_trigger = yes
				NOT = { scope:artistic_courtier_1 = this } 
			}
			weight = {
				base = 1
				modifier = {
					factor = 10
					learning > high_skill_rating
				}
			}
			save_scope_as = artistic_courtier_2
		}
		random_child = {
			limit = {
				age < 12
				root = { is_parent_of = prev }
			}
			save_scope_as = child
		}
	}

	option = { 
		name = fund_inspiration.6200.a
		trigger = {
			NOT = {
				government_has_flag = government_is_tribal # No changing amenities above what's legal for tribals
			}
		}
		add_learning_lifestyle_xp = medium_lifestyle_xp
		if = {
			limit = {
				amenity_level = { 
					type = court_fashion
					value < medium_amenity_level
				}
			}
			set_amenity_level = { type = court_fashion value = 3 }
		}
		else_if = {
			limit = {
				amenity_level = { 
					type = court_fashion
					value < high_amenity_level
				}
			}
			set_amenity_level = { type = court_fashion value = 4 }
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6200.b
		custom_tooltip = fund_inspiration.6200.b.tt
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			change_current_court_grandeur = medium_court_grandeur_gain
		}
		add_prestige = medium_prestige_gain
		end_inspiration_sponsorship = scope:inspiration
		add_gold = root.medium_gold_value
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				opinion = -20
				modifier = insulted_opinion
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6200.c
		trigger = {
			any_child = {
				age < 12
			}
		}
		scope:child = {
			add_learning_skill = 2
			add_opinion = {
				target = root
				opinion = 20
				modifier = supportive_parent
			}
		}
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				opinion = -20
				modifier = insulted_opinion
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = -0.5
			}
		}
	}
}


scripted_trigger homosexual_poet_trigger = {
	OR = {
		has_sexuality = homosexual
		has_sexuality = bisexual
	}
	OR = {
		trait_is_shunned_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:inspiration_owner }
		trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:inspiration_owner }
	}
}

scripted_trigger unloved_poet_trigger = {
	NOR = {
		any_relation = {
			type = lover
			exists = yes
		}
		any_child = {
			exists = yes
			even_if_dead = yes
		}
		any_spouse = {
			exists = yes
			even_if_dead = yes
		}
	}
}

fund_inspiration.6300 = {
	type = character_event
	title = fund_inspiration.6300.t
	override_background = {
		reference = study
	}
	desc = {
		desc = fund_inspiration.6300.intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = {
						homosexual_poet_trigger = yes
					}
				}
				desc = fund_inspiration.6300.homosexual_desc
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = {
						unloved_poet_trigger = yes
					}
				}
				desc = fund_inspiration.6300.no_relationship_desc
			}
			desc = fund_inspiration.6300.no_love_desc
		}
	}
	theme = love

	left_portrait = { 
		character = scope:inspiration_owner
		animation = worry
	}

	trigger = {
		scope:inspiration = {
			inspiration_owner = {
				exists = var:book_topic
				OR = {
					var:book_topic = flag:intrigue_the_art_of_love
					var:book_topic = flag:seduction
					var:book_topic = flag:fertility
					var:book_topic = flag:love_sorcery
					var:book_topic = flag:soulmate
				}
				NOR = {
					any_relation = {
						type = soulmate
						always = yes
					}
					has_sexuality = asexual
					has_trait = celibate
				}
			}
		}
	}

	immediate = {
		random_vassal = {
			limit = { has_trait = poet }
			save_scope_as = inspiration_owner
		}
	}

	
	option = { 
		name = fund_inspiration.6300.a
		trigger = {
			scope:inspiration_owner = { 
				unloved_poet_trigger = no
				homosexual_poet_trigger = no
			}
		}
		duel = {
			skill = intrigue
			target = scope:inspiration_owner
			6 = {
				custom_tooltip = fund_inspiration.6300.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.3
				}
				hidden_effect = {
					send_interface_toast = {
						left_icon = scope:inspiration_owner
						title = fund_inspiration.6300.a.success
						show_as_tooltip = {
							scope:inspiration_owner = {
								change_artifact_book_content_quality_effect = { AMOUNT = 2 }
							}
						}
					}
				}
			}
			4 = {
				custom_tooltip = fund_inspiration.6300.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.3
				}
				hidden_effect = {
					send_interface_toast = {
						left_icon = scope:inspiration_owner
						title = fund_inspiration.6300.a.failure
						show_as_tooltip = {
							scope:inspiration_owner = {
								change_artifact_book_content_quality_effect = { AMOUNT = -2 }
							}
						}
					}
				}
			}
		}
	}

	option = {
		name = fund_inspiration.6300.b
		trigger = {
			scope:inspiration_owner = {
				homosexual_poet_trigger = no
				unloved_poet_trigger = yes
				is_attracted_to_gender_of = root
				might_cheat_on_every_partner_trigger = yes
			}
			is_attracted_to_gender_of = scope:inspiration_owner
			might_cheat_on_every_partner_trigger = yes
		}
		had_sex_with_effect = {
			CHARACTER = scope:inspiration_owner
			PREGNANCY_CHANCE = 25
		}
		scope:inspiration_owner = {
			progress_towards_lover_effect = {
				CHARACTER = root
				REASON = lover_inspiration_help
				OPINION = default_lover_opinion
			}
			change_artifact_book_content_quality_effect = { AMOUNT = 4 }
		}
	}

	option = {
		name = fund_inspiration.6300.c
		trigger = {
			is_attracted_to_gender_of = scope:inspiration_owner
			OR = {
				can_set_relation_potential_lover_trigger = { CHARACTER = scope:inspiration_owner }
				can_set_relation_lover_trigger = { CHARACTER = scope:inspiration_owner }
			}
			scope:inspiration_owner = {
				homosexual_poet_trigger = no
			}
		}
		progress_towards_lover_effect = {
			CHARACTER = scope:inspiration_owner
			REASON = lover_inspiration_strikes
			OPINION = 20
		}
		scope:inspiration_owner = {
			change_artifact_book_content_quality_effect = { AMOUNT = 4 }
		}
	}

	option = {
		name = fund_inspiration.6300.d
		trigger = {
			scope:inspiration_owner = {
				homosexual_poet_trigger = yes
			}
			OR = {
				has_sexuality = homosexual
				has_sexuality = bisexual
			}
			OR = { #Only really makes sense to get the later lover same sex love event if it actually is same sex love
				AND = {
					is_female = yes
					scope:inspiration_owner = { is_female = yes }
				}
				AND = {
					is_male = yes
					scope:inspiration_owner = { is_male = yes }
				}
			}
			is_attracted_to_gender_of = scope:inspiration_owner
			OR = {
				can_set_relation_potential_lover_trigger = { CHARACTER = scope:inspiration_owner }
				can_set_relation_lover_trigger = { CHARACTER = scope:inspiration_owner }
			}
		}
		scope:inspiration_owner = {
			change_artifact_book_content_quality_effect = { AMOUNT = 4 }
		}
		progress_towards_lover_effect = {
			CHARACTER = scope:inspiration_owner
			REASON = lover_inspiration_allowed
			OPINION = 20
		}
		add_character_flag = fund_inspiration_6301_lover
		trigger_event = {
			id = fund_inspiration.6301
			days = 10
		}
	}
	option = {
		name = fund_inspiration.6300.e
		trigger = {
			scope:inspiration_owner = {
				homosexual_poet_trigger = yes
			}
		}
		scope:inspiration_owner = {
			change_artifact_book_content_quality_effect = { AMOUNT = 4 }
		}
		progress_towards_friend_effect = {
			CHARACTER = scope:inspiration_owner
			OPINION = 20
			REASON = friend_supported_poet
		}
		add_character_flag = fund_inspiration_6301_friend
		trigger_event = {
			id = fund_inspiration.6301
			days = 10
		}
	}
	option = {
		name = fund_inspiration.6300.f
		random_list = {
			6 = {
				scope:inspiration_owner = {
					change_artifact_book_content_quality_effect = { AMOUNT = 2 }
				}
				hidden_effect = {
					send_interface_toast = {
						left_icon = scope:inspiration_owner
						title = fund_inspiration.6300.a.success
						show_as_tooltip = {
							scope:inspiration_owner = {
								change_artifact_book_content_quality_effect = { AMOUNT = 2 }
							}
						}
					}
				}
			}

			4 = {
				hidden_effect = {
					send_interface_toast = {
						left_icon = scope:inspiration_owner
						title = fund_inspiration.6300.a.failure
						show_as_tooltip = {
							end_inspiration_sponsorship = scope:inspiration
						}
					}
				}
				end_inspiration_sponsorship = scope:inspiration
			}
		}
	}
}

#Poet sends you same sex love poetry if you encouraged them

fund_inspiration.6301 = {
	type = letter_event
	opening = {
		desc = fund_inspiration.6301.t
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = fund_inspiration_6301_lover
				}
				desc = fund_inspiration.6301.lover_desc
			}
			triggered_desc = {
				trigger = {
					has_character_flag = fund_inspiration_6301_friend
				}
				desc = fund_inspiration.6301.friend_desc
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { is_female = yes } 
				}
				desc = fund_inspiration.6301.female_desc
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = { is_male = yes } 
				}
				desc = fund_inspiration.6301.male_desc
			}
		}
		triggered_desc = {
			trigger = {
				trait_is_criminal_in_faith_trigger = { TRAIT = sodomite FAITH = root.faith GENDER_CHARACTER = scope:inspiration_owner }
			}
			desc = fund_inspiration.6301.crime_desc
		}
	}
	sender = scope:inspiration_owner

	weight_multiplier = {
		base = 1
	}


	immediate = {
		hidden_effect = {
			scope:inspiration_owner = {
				if = {
					limit = { is_female = yes }
					save_scope_as = owner
					create_artifact = {
						name = witch_queen_love_poem_name
						description = witch_queen_love_poem_description
						type = book
						visuals = book
						modifier = artifact_same_faith_opinion_negative_1_modifier
						save_scope_as = witch_queen_love_poem
					}
					scope:witch_queen_love_poem = {
						add_artifact_modifier = artifact_seduce_scheme_phase_duration_add_2_modifier
						add_artifact_modifier = artifact_tolerance_advantage_mod_1_modifier
						flag_as_trash_artifact = yes
					}
				}
				else = {
					save_scope_as = owner
					create_artifact = {
						name = prince_archivist_love_poem_name
						description = prince_archivist_love_poem_description
						type = book
						visuals = book
						modifier = artifact_same_faith_opinion_negative_1_modifier
						save_scope_as = prince_archivist_love_poem
					}
					scope:prince_archivist_love_poem = {
						add_artifact_modifier = artifact_seduce_scheme_phase_duration_add_2_modifier
						add_artifact_modifier = artifact_tolerance_advantage_mod_1_modifier
						flag_as_trash_artifact = yes
					}
				}
			}
		}
		scope:inspiration_owner = {
			change_artifact_book_content_quality_effect = { AMOUNT = 2 }
		}
	}

	after = {
		remove_character_flag = fund_inspiration_6301_friend
		remove_character_flag = fund_inspiration_6301_lover
	}

	option = {
		name = fund_inspiration.6301.a
		if = {
			limit = {
				scope:inspiration_owner = {
					is_male = yes
				}
			}
			scope:prince_archivist_love_poem = { set_owner = root }
		}
		else = {
			scope:witch_queen_love_poem = { set_owner = root }
		}
		add_intrigue_lifestyle_xp = medium_lifestyle_xp
		if = {
			limit = { has_character_flag = fund_inspiration_6301_lover }
			progress_towards_lover_effect = {
				CHARACTER = scope:inspiration_owner
				REASON = lover_inspiration_treasure
				OPINION = 20
			}
		}
	}

	option = {
		name = fund_inspiration.6301.b
		if = {
			limit = {
				scope:inspiration_owner = {
					is_male = yes
				}
			}
			scope:prince_archivist_love_poem = { set_owner = root }
		}
		else = {
			scope:witch_queen_love_poem = { set_owner = root }
		}
		every_courtier_or_guest = {
			limit = {
				NOR = {
					has_trait = compassionate
					this = inspiration_owner
					is_close_family_of = root
				}
			}
			custom = all_courtiers_and_guests
			add_opinion = {
				target = root
				modifier = insult_opinion
				opinion = -10
			}
		}
		every_courtier = {
			limit = { 
				has_trait = compassionate 
			}
			custom = all_compassionate_in_the_court
			add_opinion = {
				target = root
				modifier = pity_opinion
				opinion = 15
			}
		}
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			change_current_court_grandeur = medium_court_grandeur_gain
		}
		if = {
			limit = { has_character_flag = fund_inspiration_6301_friend }
			progress_towards_friend_effect = {
				CHARACTER = scope:inspiration_owner
				OPINION = 20
				REASON = friend_arranged_reading
			}
		}
	}
}


#Bringing music to the jungle by Isabella Welch

fund_inspiration.6500 = {
	type = character_event
	title = fund_inspiration.6500.t
	desc = 	{
		desc = fund_inspiration.6500.introduction
		desc = fund_inspiration.6500.desc
		desc = fund_inspiration.6500.action
	}

	theme = hunting
	override_background = {
		reference = wilderness_forest
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	lower_left_portrait = {
		character = scope:court_musician
	}

	artifact = {
		target = scope:leopard_hat
		position = lower_center_portrait
	}
	
	cooldown = { years = 15 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = jungle
			}
		}
		NOT = {
			any_character_artifact = {
				has_variable = leopard_hat
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		if = {
			limit = { employs_court_position = court_musician_court_position }
			random_court_position_holder = {
				type = court_musician_court_position
				save_scope_as = court_musician
			}
		}
		else_if ={
			limit = { employs_court_position = court_poet_court_position }
			random_court_position_holder = {
				type = court_poet_court_position
				save_scope_as = court_musician
			}
		}
		else_if = {
			limit = { employs_court_position = court_jester_court_position }
			random_court_position_holder = {
				type = court_jester_court_position
				save_scope_as = court_musician
			}
		}
		else_if = {
			limit = {
				any_courtier = {
					has_trait = poet
				}
			}
			random_courtier = {
				limit = { has_trait = poet }
				save_scope_as = court_musician
			}
		}
		else = {
			random_courtier = {
				save_scope_as = court_musician
			}
		}
		hidden_effect = {
			set_artifact_rarity_common = yes
			save_scope_as = owner # Needed for 'visuals = crown'
			scope:inspiration_owner = {
				create_artifact = {
					name = leopard_hat_name
					description = leopard_hat_description
					template = crown_wearable_template
					wealth = scope:wealth
					quality = scope:quality
					type = helmet
					visuals = crown
					modifier = artifact_prowess_2_modifier
					save_scope_as = leopard_hat
				}
				hidden_effect_new_object = {
					scope:leopard_hat = {
						flag_as_trash_artifact = yes
						set_variable = {
							name = leopard_hat
							value = yes
						}
					}
				}
			}
		}
	}

	option = { # Show everyone the music, will they like it?
		name = fund_inspiration.6500.a
		scope:inspiration_owner = {
			duel = {
				skill = diplomacy
				value = 8
				40 = {
					desc = fund_inspiration.6500.a.success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 0.5
					}
					send_interface_toast = {
						title = fund_inspiration.6500.a.success
						left_icon = scope:inspiration_owner
						scope:inspiration_owner = {
							change_artifact_quality_effect = {
								AMOUNT = 2
							}
						}
						scope:inspiration_owner = {
							add_diplomacy_skill = 2
						}
					}
				}
				10 = {
					desc = fund_inspiration.6500.a.failure
					send_interface_toast = {
						title = fund_inspiration.6500.a.failure
						left_icon = scope:inspiration_owner
						scope:inspiration_owner = {
							increase_wounds_effect = { REASON = poison }
						}
					}
				}
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}

	option = { # Adventurer flees
		name = fund_inspiration.6500.b
		scope:inspiration_owner = {
			duel = {
				skill = prowess
				value = 8
				40 = {
					desc = fund_inspiration.6500.b.success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 0.5
					}
					send_interface_toast = {
						title = fund_inspiration.6500.b.success
						left_icon = scope:inspiration_owner
						scope:inspiration_owner = {
							add_prowess_skill = 2
						}
						scope:inspiration_owner = {
							change_artifact_quality_effect = {
								AMOUNT = 2
							}
						}
					}
				}
				10 = {
					desc = fund_inspiration.6500.b.failure
					hidden_effect = {
						send_interface_toast = {
							title = fund_inspiration.6500.b.failure
							left_icon = scope:inspiration_owner
							scope:inspiration_owner = {
								increase_wounds_effect = { REASON = fight }
							}
						}
					}
				}
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = { # Adventurer fights a wild beast
		name = fund_inspiration.6500.c
		random_list = {
			10 = {
				custom_tooltip = fund_inspiration.6500.c.tt
				modifier = {
					add = 25
					scope:inspiration_owner = {
						has_trait = lifestyle_hunter
					}
				}
				modifier = {
					add = 25
					scope:inspiration_owner = {
						prowess > medium_skill_rating
					}
				}
				scope:leopard_hat = {
					set_owner = scope:inspiration_owner
				}
				hidden_effect = {	
					send_interface_toast = {
						title = fund_inspiration.6500.c.tt
						left_icon = scope:inspiration_owner
						scope:inspiration_owner = {
							change_artifact_quality_effect = {
								AMOUNT = 2
							}
						}
					}
				}
			}

			10 = {
				custom_tooltip = fund_inspiration.6500.c.tt_failure
				modifier = {
					add = 25
					scope:inspiration_owner = {
						prowess < medium_skill_rating
					}
				}
				hidden_effect = {	
					send_interface_toast = {
						title = fund_inspiration.6500.c.tt_failure
						left_icon = scope:inspiration_owner
						scope:inspiration_owner = {
							increase_wounds_effect = { REASON = fight }
						}
					}
				}
			}
		}
		ai_chance = {
			base = 5
			ai_value_modifier = {
				ai_greed = 0.5
			}
		}
	}
}

# Dragging a boat up a cliff by Isabella Welch

scripted_trigger sisyphus_nickname_trigger = {
	OR = {
		has_title = title:k_italy
		has_title = title:k_romagna
		has_title = title:k_sardinia
		has_title = title:e_italy
		has_title = title:e_roman_empire
		capital_province = {
			geographical_region = world_europe_west_britannia
			geographical_region = world_europe_west_germania
			geographical_region = world_europe_west_francia
			geographical_region = world_europe_west_iberia
			geographical_region = world_europe_west
			geographical_region = world_europe_south_italy
			geographical_region = world_europe_south
		}
		culture = { has_cultural_pillar = heritage_byzantine }
	}
}

fund_inspiration.6501 = {
	type = character_event
	title = fund_inspiration.6501.t
	desc = 	{
		desc = fund_inspiration.6500.introduction
		desc = fund_inspiration.6501.desc
		desc = fund_inspiration.6500.action
	}

	theme = hunting
	override_background = {
		reference = wilderness_mountains
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	cooldown = { years = 10 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = hills
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	option = { # Adventurer cuts their losses
		name = fund_inspiration.6501.a
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = -2
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = { # Adventurer attempts a ridiculous dragging of the boat over land
		name = fund_inspiration.6501.b
		scope:inspiration_owner = {
			duel = {
				skill = martial
				value = 10
				40 = {
					desc = fund_inspiration.6501.b.success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 0.5
					}
					modifier = {
						add = 25
						scope:inspiration_owner = {
							has_lifestyle = martial_lifestyle
						}
					}
					modifier = {
						add = 25
						scope:inspiration_owner = {
							has_trait = strategist
						}
					}
					root = {
						send_interface_toast = {
							title = fund_inspiration.6501.b.success
							left_icon = scope:inspiration_owner
							scope:inspiration_owner = {
								add_prowess_skill = 2
								if = {
									limit = {
										root = { sisyphus_nickname_trigger = yes }
									}
									give_nickname = nick_sisyphus
								}
							}
							scope:inspiration_owner = {
								change_artifact_quality_effect = {
									AMOUNT = 4
								}
							}
							add_prestige = major_prestige_gain
						}
					}
				}
				10 = {
					desc = fund_inspiration.6501.b.failure
					hidden_effect = {
						root = {
							send_interface_toast = {
								title = fund_inspiration.6501.b.failure
								left_icon = scope:inspiration_owner
								remove_short_term_gold = major_gold_value
							}
						}
					}
					remove_short_term_gold = major_gold_value
				}
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 0.5
			}
			modifier = {
				short_term_gold < massive_gold_value
				factor = 0
			}
			modifier = {
				is_at_war = yes
				factor = 0
			}
		}
	}

	option = { # Adventurer gives up and buys a new boat
		name = fund_inspiration.6501.c
		remove_short_term_gold = medium_gold_value
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = -0.5
			}
			modifier = {
				short_term_gold < major_gold_value
				factor = 0
			}
			modifier = {
				is_at_war = yes
				factor = 0
			}
		}
	}
}

#Adventurer in the desert dreaming of you

fund_inspiration.6502 = {
	type = character_event
	title = fund_inspiration.6502.t
	desc = 	{
		desc = fund_inspiration.6500.introduction
		desc = fund_inspiration.6502.desc
	}

	theme = hunting
	override_background = {
		reference = wilderness_desert 
	}
	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	cooldown = { years = 20 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = desert
			}
		}
		can_set_relation_lover_trigger =  { CHARACTER = scope:inspiration_owner }
	}

	weight_multiplier = {
		base = 1
	}

	option = { # You are indeed missing your adventurer
		name = fund_inspiration.6502.a
		trigger = {
			has_relation_potential_lover = scope:inspiration_owner
			can_set_relation_lover_trigger = { CHARACTER = scope:inspiration_owner }
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = 2
			}
		}
		progress_towards_lover_effect = {
			CHARACTER = scope:inspiration_owner
			REASON = lover_adventurer_thirst
			OPINION = 20
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
	}

	option = { # try and wrangle the adventurer into bringing back better items
		name = fund_inspiration.6502.b
		trigger = {
			NOT = { has_relation_potential_lover = scope:inspiration_owner }
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = 2
			}
		}
		progress_towards_lover_effect = {
			CHARACTER = scope:inspiration_owner
			REASON = lover_adventurer_thirst
			OPINION = 20
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.5
			}
		}
	}

	option = { # roll your eyes
		name = fund_inspiration.6502.c
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = disappointed_opinion
			opinion = -15
		}
		scope:inspiration_owner = {
			add_character_modifier = {
				modifier = dying_of_thirst_modifier
				years = 2
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}
}

#Burial mound entry

fund_inspiration.6503 = {
	type = character_event
	title = fund_inspiration.6503.t
	theme = hunting
	desc = {
		desc = fund_inspiration.6500.introduction
		desc = fund_inspiration.6503.desc
		desc = fund_inspiration.6500.action
	}
	
	override_background = {
		reference = wilderness_steppe
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}
	
	cooldown = { years = 15 }
	
	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = steppe
				geographical_region = world_steppe_west
			}
		}
		NOR = {
			any_character_artifact = {
				has_variable = kurgan_ornament
			}
			any_character_artifact = {
				has_variable = kurgan_saddle
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		hidden_effect = {
			scope:inspiration_owner = {
				create_artifact = {
					name = kurgan_ornament_name
					description = kurgan_ornament_description
					type = miscellaneous
					visuals = small_box
					modifier = artifact_court_grandeur_baseline_add_1_modifier
					save_scope_as = kurgan_ornament
				}
			}
			hidden_effect_new_object = {
				scope:kurgan_ornament = {
					flag_as_trash_artifact = yes
					set_variable = {
						name = kurgan_ornament
						value = yes
					}
				}
			}
		}
		hidden_effect = {
			scope:inspiration_owner = {
				create_artifact = {
					name = kurgan_saddle_name
					description = kurgan_saddle_description
					type = miscellaneous
					visuals = medium_box
					modifier = artifact_monthly_martial_lifestyle_xp_1_modifier
					save_scope_as = kurgan_saddle
				}
			}
			hidden_effect_new_object = {
				scope:kurgan_saddle = {
					flag_as_trash_artifact = yes
					set_variable = {
						name = kurgan_saddle
						value = yes
					}
				}
			}
		}
	}

	option = {  # get a fancy little bauble from the tomb
		name = fund_inspiration.6503.a
		scope:kurgan_ornament = {
			set_owner = root
		}
		hidden_effect = { destroy_artifact = scope:kurgan_saddle }
		scope:inspiration_owner = {
			add_character_modifier = {
				modifier = tomb_robber_modifier
				years = 2
			}
		}
		add_character_modifier = {
			modifier = tomb_robber_modifier
			years = 2
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_greed = 0.5
			}
		}
	}

	option = { # study the saddles and horsemanship of the scythians
		name = fund_inspiration.6503.b
		scope:kurgan_saddle = {
			set_owner = root
		}
		hidden_effect = { destroy_artifact = scope:kurgan_ornament }
		scope:inspiration_owner = {
			add_character_modifier = {
				modifier = tomb_robber_modifier
				years = 2
			}
		}
		add_character_modifier = {
			modifier = tomb_robber_modifier
			years = 2
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}

	option = { # refuse to rob the tomb
		name = fund_inspiration.6503.c
		add_character_modifier = {
			modifier = respect_for_the_dead_modifier
			years = 2
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_boldness = -0.5
			}
		}
	}
}

#Adventurer took a farmhand as a lover

fund_inspiration.6504 = {
	type = character_event
	title = fund_inspiration.6504.t
	theme = hunting
	desc = {
		desc = fund_inspiration.6500.introduction
		desc = fund_inspiration.6504.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = {
						has_character_flag = adventurer_pregnant_lover_flag
					}
				}
				desc = fund_inspiration.6504.pregnant
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = {
						has_character_flag = adventurer_female_lover_flag
					}
				}
				desc = fund_inspiration.6504.female_lover
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = {
						has_character_flag = adventurer_male_lover_flag
						has_sexuality = homosexual
					}
				}
				desc = fund_inspiration.6504.male_lover_homosexual
			}
			desc = fund_inspiration.6504.male_lover
		}
		triggered_desc = {
			trigger = {
				NOT = {
					scope:inspiration_owner = {
						has_character_flag = adventurer_pregnant_lover_flag
					}
				}
			}
			desc = fund_inspiration.6504.lover_ultimatum
		}
	}
	
	override_background = {
		reference = farmland
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	right_portrait = { 
		character = scope:adventurer_lover
		animation = love
	}

	immediate = {
		scope:adventurer_homosexual_secret ?= { reveal_to = root }
		scope:adventurer_lover_secret ?= { reveal_to = root }
	}

	option = { # tell the adventurer to begone
		name = fund_inspiration.6504.a
		custom_tooltip = fund_inspiration.6504.a.tt
		trigger = {
			NOT = {
				scope:inspiration_owner = {
					has_character_flag = adventurer_pregnant_lover_flag
				}
			}
		}
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			change_current_court_grandeur = medium_court_grandeur_gain
		}
		end_inspiration_sponsorship = scope:inspiration
		remove_courtier_or_guest = scope:inspiration_owner
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = -0.5
			}
		}
	}

	option = { # let the adventurer and their lover come to court
		name = fund_inspiration.6504.b
		trigger = {
			NOT = {
				scope:inspiration_owner = {
					has_character_flag = adventurer_pregnant_lover_flag
				}
			}
		}
		add_courtier = scope:adventurer_lover
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			change_current_court_grandeur = medium_court_grandeur_loss
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = 2
			}
		}
		scope:lover_homosexual_secret ?= { reveal_to = root }
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = 0.5
			}
		}
	}

	option = { # express sympathy for the child if the lover is pregnant
		name = fund_inspiration.6504.c
		trigger = {
			scope:inspiration_owner = {
				has_character_flag = adventurer_pregnant_lover_flag
			}
		}
		add_courtier = scope:adventurer_lover
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			change_current_court_grandeur = medium_court_grandeur_loss
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = 2
			}
		}
		scope:lover_homosexual_secret ?= { reveal_to = root }
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = 0.5
			}
		}
	}
	option = { # absolutely reject peasants in the court
		name = fund_inspiration.6504.d
		trigger = {
			scope:inspiration_owner = {
				has_character_flag = adventurer_pregnant_lover_flag
			}
		}
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			change_current_court_grandeur = medium_court_grandeur_gain
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = -2
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = -0.5
			}
		}
	}
}

fund_inspiration.6513 = {
	type = character_event
	hidden = yes
	cooldown = { years = 15 }

	weight_multiplier = {
		base = 1
		modifier = {
			scope:inspiration_owner = { has_trait = lustful }
			factor = 2
		}
		modifier = {
			scope:inspiration_owner = { has_trait = rakish }
			factor = 2
		}
	}

	trigger = {
		scope:inspiration = { has_inspiration_type = adventure_inspiration }
		scope:inspiration_owner = {
			location = {
				terrain = farmlands
			}
			NOR = { 
				has_trait = chaste
				has_sexuality = asexual
			}
			might_cheat_on_every_partner_trigger = yes
		}
	}

	immediate = {
		scope:inspiration_owner = {
			location = { save_scope_as = location_template }
		}
		if = { # Male adventurer impregnates someone
			limit = {
				scope:inspiration_owner = { # Must be male and attracted to women
					is_male = yes
					is_attracted_to_women = yes
					can_have_children = yes
				}
			}
			create_character = {
				location = scope:inspiration_owner.location
				template = adventurer_pregnant_lover_character
				faith = scope:location_template.faith
				culture = scope:location_template.culture
				save_scope_as = adventurer_lover
			}
			scope:adventurer_lover = {
				if = {
					limit = { can_have_children = yes }
					make_pregnant = { father = scope:inspiration_owner }
					scope:inspiration_owner = { add_character_flag = adventurer_pregnant_lover_flag }
				}
				else = {
					scope:inspiration_owner = { add_character_flag = adventurer_female_lover_flag }
				}
			}
		}
		else = { # Any other male or female lover combo
			hidden_effect = {
				random_list = {
					10 = { # Female lover
						trigger = {
							scope:inspiration_owner = { is_attracted_to_women = yes }
						}
						create_character = {
							location = scope:inspiration_owner.location
							template = adventurer_female_lover_character
							faith = scope:location_template.faith
							culture = scope:location_template.culture
							save_scope_as = adventurer_lover
						}
						scope:inspiration_owner = { add_character_flag = adventurer_female_lover_flag }
					}
					10 = { # Male lover
						trigger = {
							scope:inspiration_owner = { is_attracted_to_men = yes }
						}
						create_character = {
							location = scope:inspiration_owner.location
							template = adventurer_male_lover_character
							faith = scope:location_template.faith
							culture = scope:location_template.culture
							save_scope_as = adventurer_lover
						}
						scope:inspiration_owner = { add_character_flag = adventurer_male_lover_flag }
					}
				}
			}
		}
		scope:adventurer_lover = { # Catch bad sexuality matches
			if = {
				limit = {
					NOT = { is_attracted_to_gender_of = scope:inspiration_owner }
				}
				set_sexuality = bisexual
			}
		}
		scope:inspiration_owner = {
			# Lover relation
			set_random_lover_reason = { TARGET = scope:adventurer_lover }
			# Lover secret
			if = {
				limit = {
					any_secret = {
						secret_type = secret_lover
						secret_target = scope:adventurer_lover
					}
				}
				random_secret = {
					limit = {
						secret_type = secret_lover
						secret_target = scope:adventurer_lover
					}
					save_scope_as = adventurer_lover_secret
				}
			}
			# Homosexual secret
			if = {
				limit = {
					sex_same_as = scope:adventurer_lover
					trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = sodomite GENDER_CHARACTER = scope:inspiration_owner }
				}
				if = {
					limit = {
						NOT = {
							any_secret = { secret_type = secret_homosexual }
						}
					}
					give_homosexual_secret_or_nothing_effect = yes
				}
				random_secret = {
					limit = { secret_type = secret_homosexual }
					save_scope_as = adventurer_homosexual_secret
				}
			}
		}
		# Other homosexual secret
		scope:adventurer_lover = {
			if = {
				limit = {
					sex_same_as = scope:inspiration_owner
					trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = sodomite GENDER_CHARACTER = scope:adventurer_lover }
				}
				if = {
					limit = {
						NOT = {
							any_secret = { secret_type = secret_homosexual }
						}
					}
					give_homosexual_secret_or_nothing_effect = yes
				}
				random_secret = {
					limit = { secret_type = secret_homosexual }
					save_scope_as = lover_homosexual_secret
				}
			}
		}
		trigger_event = fund_inspiration.6504
	}
}

#Oasis event, or, should I say, the CK3 beach episode

fund_inspiration.6505 = {
	type = character_event
	title = fund_inspiration.6505.t
	desc = 	{
		desc = fund_inspiration.6500.introduction
		desc = fund_inspiration.6505.desc
	}
	theme = hunting
	override_background = {
		reference = wilderness_desert
	}
	left_portrait = {
		character = scope:inspiration_owner
		animation = happiness
		triggered_outfit = {
			remove_default_outfit = yes
			outfit_tags = { no_clothes }
		}
	}
	artifact = {
		target = scope:naked_tapestry
		position = lower_center_portrait
	}
	
	cooldown = { years = 10 }
	
	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = oasis
			}
		}
		NOT = {
			any_character_artifact = {
				has_variable = naked_tapestry
			}
		}
	}

	weight_multiplier = {
		base = 2
	}

	immediate = {
		hidden_effect = {
			save_scope_as = owner
			set_artifact_rarity_common = yes
			scope:inspiration_owner = {
				create_artifact = {	
					name = naked_tapestry_name
					description = naked_tapestry_description
					visuals = tapestry
					type = tapestry
					quality = scope:quality
					wealth = scope:wealth
					modifier = artifact_attraction_opinion_2_modifier
					save_scope_as = naked_tapestry
				}
				add_character_flag = is_naked
				hidden_effect_new_object = {
					scope:naked_tapestry = {
						flag_as_trash_artifact = yes
						set_variable = {
							name = naked_tapestry
							value = yes
						}
					}
				}
			}
		}
	}

	option = { # destroy the naked tapestry
		name = {
			trigger = { 
				has_trait = one_eyed
			}
			text = fund_inspiration.6505.a_one_eyed
		}
		name = {
			trigger = { 
				has_trait = blind
			}
			text = fund_inspiration.6505.a_blind
		}
		name = fund_inspiration.6505.a
		destroy_artifact = scope:naked_tapestry
		reverse_add_opinion = {
			target = scope:inspiration_owner
			opinion = -20
			modifier = insulted_opinion
		}
		if = {
			limit = { NOT = { has_faith = faith:adamites } }
			add_piety = medium_piety_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = { # appreciate the salacious tapestry... in private
		name = fund_inspiration.6505.b
		scope:naked_tapestry = {
			set_owner = root
		}
		add_intrigue_lifestyle_xp = medium_lifestyle_xp
		reverse_add_opinion = {
			target = scope:inspiration_owner
			opinion = 20
			modifier = pleased_opinion
		}
		if = {
			limit = {
				has_trait = chaste
			}
			remove_trait = chaste
			add_trait = lustful
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
	}

	option = { # flex the naked tapestry in front of your whole court
		name = fund_inspiration.6505.c
		trigger = {
			NOT = { has_faith = faith:adamites }
		}
		scope:naked_tapestry = {
			set_owner = root
		}
		every_courtier = {
			limit = {
				has_trait = lustful
			}
			custom = all_lustful_in_the_court
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 20
			}
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			opinion = 20
			modifier = pleased_opinion
		}
		if = {
			limit = {
				has_royal_court = yes
				has_dlc_feature = royal_court
			}
			change_current_court_grandeur = minor_court_grandeur_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}
	option = { #adamites find it sacred
		name = fund_inspiration.6505.d
		trigger = {
			has_faith = faith:adamites
		}
		scope:naked_tapestry = {
			set_owner = root
		}
		add_piety = medium_piety_gain
		reverse_add_opinion = {
			target = scope:inspiration_owner
			opinion = 20
			modifier = pleased_opinion
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}
	
	after = {
        scope:inspiration_owner = {
            if = {
                limit = { has_character_flag = is_naked }
                remove_character_flag = is_naked
            }
        }
    } 
}

#Adventurer hasn't gone on the adventure, is in a local tavern by Isabella Welch
#as pope urban iii would say, 'the tavern sins'
scripted_trigger deadbeat_adventurer_trigger = {
	OR = {
		has_trait = rakish
		has_trait = lazy
		has_trait = drunkard
		has_trait = gluttonous
		has_trait = drunkard
		has_trait = deceitful
		has_trait = greedy
	}
	NOT = { has_character_flag = was_deadbeat }
	adventure_inspiration_average_skill_value < high_inspiration_skill
}

fund_inspiration.6400 = {
	type = character_event
	title = fund_inspiration.6400.t
	desc = fund_inspiration.6400.desc
	theme = realm
	override_background = {
		reference = tavern
	}
	left_portrait = { 
		character = scope:inspiration_owner
		animation = scheme
	}
	right_portrait = { 
		character = root
		animation = shock
	}

	cooldown = { years = 10 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
			scope:inspiration_owner = {
				deadbeat_adventurer_trigger = yes
			}
		}
	}

	weight_multiplier = {
		base = 0.25
		modifier = {
			add = 0.75
			scope:inspiration_owner = {
				OR = {
					has_trait = drunkard
					has_trait = lazy
				}
			}
		}
		modifier = {
			add = -0.25
			scope:inspiration_owner = {
				adventure_inspiration_average_skill_value >= medium_inspiration_skill
			}
		}
	}

	immediate = {
		scope:inspiration = {
			change_inspiration_progress = -5
		}
		scope:inspiration_owner = {
			if = {
				limit = {
					NOT = { has_trait = drunkard }
				}
				add_trait = drunkard
			}
			add_character_flag = was_deadbeat
		}
		hidden_effect = {
			scope:inspiration_owner = {
				set_location = {
					location = root.capital_province
					stick_to_location = yes
				}
			}
		}
	}

	option = { 
		name = fund_inspiration.6400.a
		duel = {
			skill = stewardship
			target = scope:inspiration_owner
			30 = {
				desc = fund_inspiration.6400.a.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.2
				}
				send_interface_toast = {
					title = fund_inspiration.6400.a.success
					custom_tooltip = fund_inspiration.6400.a.success_continue
					left_icon = scope:inspiration_owner
				}
			}
			20 = {
				desc = fund_inspiration.6400.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.2
				}
				send_interface_toast = {
					title = fund_inspiration.6400.a.failure
					left_icon = scope:inspiration_owner
					remove_short_term_gold = minor_gold_value
					end_inspiration_sponsorship = scope:inspiration
				}
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_rationality = 0.5
			}
		}
	}

	option = {
		name = fund_inspiration.6400.b
		end_inspiration_sponsorship = scope:inspiration
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
				opinion = -20
			}
		}
		root.capital_county = {
			add_county_modifier = {
				modifier = county_chastised_beloved_adventurer_modifier
				years = 25
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_greed = 0.5
			}
		}
	}
}


#Adventurer is being very precious, not really suited for the outdoors

fund_inspiration.6506 = {
	type = character_event
	title = fund_inspiration.6506.t
	desc = 	{
		desc = fund_inspiration.6506.introduction
		desc = fund_inspiration.6506.desc
	}

	theme = hunting
	override_background = {
		reference = wilderness_steppe
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}
	
	cooldown = { years = 10 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = wetlands
			}
			NOT = {
				has_trait = rough_terrain_expert
			}
		}
		NOT = {
			any_character_artifact = {
				has_variable = frogspawn_jar
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.5
			scope:inspiration_owner = {
				OR = {
					has_trait = craven
					has_trait = lazy
					has_trait = gluttonous
					has_trait = irritable
					has_trait = profligate
				}
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			#To stagger any following events
			add_character_flag = {
				flag = fund_adventure_inspiration_event_cooldown
				days = { 30 60 }
			}
			create_artifact = {
				name = frogspawn_jar_name
				description = frogspawn_jar_description
				type = miscellaneous
				visuals = glazed_jar
				modifier = artifact_fertility_gain_1_modifier
				save_scope_as = frogspawn_jar
				history = {
					type = discovered
					actor = scope:inspiration_owner
					recipient = root
					location = scope:inspiration_owner.location
				}
			}
			hidden_effect_new_object = {
				scope:frogspawn_jar = {
					flag_as_trash_artifact = yes
					set_variable = {
						name = frogspawn_jar
						value = yes
					}
				}
			}
		}
		scope:frogspawn_jar = {
			set_owner = root
		}
	}

	option = { #try and convince them to keep going
		name = fund_inspiration.6506.a
		scope:inspiration_owner = {
			add_stress = major_stress_gain
		}
		add_opinion = {
			target = root
			modifier = cruelty_opinion
			opinion = -20
		}
		scope:inspiration_owner = {
			hidden_effect = {
				duel = {
					skill = prowess
					value = 8
					40 = {
						compare_modifier = {
							value = scope:duel_value
							multiplier = 0.5
						}
						change_artifact_quality_effect = {
							AMOUNT = -2
						}
					}
					30 = {
						compare_modifier = {
							value = scope:duel_value
							multiplier = -0.5
						}
						hidden_effect = {
							add_character_flag = adventurer_stuck_in_swamp
						}
					}
				}
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_honor = 0.5
			}
		}
	}

	option = { #let them go to easier lands
		name = fund_inspiration.6506.b
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = -2
			}
			add_opinion = {
				target = root
				modifier = kindness_opinion
				opinion = 20
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_greed = -0.5
			}
		}
	}
}

#Adventurer is travelling through reasonably pleasant lands, gets bullied by the county holder who doesn't like ROOT

fund_inspiration.6507 = {
	type = character_event
	title = fund_inspiration.6507.t
	desc = 	{
		desc = fund_inspiration.6507.introduction
		desc = fund_inspiration.6507.desc
	}

	theme = hunting
	override_background = {
		reference = wilderness_steppe
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}


	cooldown = { years = 20 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			NOT = { has_character_flag = had_fund_inspiration.6507 }
			location = {
				terrain = plains
				exists = this.barony.holder
				this.barony.holder = {
					is_adult = yes
					opinion = {
						target = root
						value <= low_negative_opinion
					}
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:inspiration_owner = {
			location = {
				this.barony.holder = { save_scope_as = grumpy_liege }
			}
			add_character_flag = had_fund_inspiration.6507
			if = {
				limit = {
					NOR = { 
						has_trait = blind
						has_trait = one_eyed
					}
				}
				add_trait = one_eyed
			}
			else_if = {
				limit = {
					has_trait = one_eyed
					NOT = { has_trait = blind }
				}
				add_trait = blind
			}
		}
	}

	option = { #midly respond by denouncing the guy who did this
		name = fund_inspiration.6507.a
		hidden_effect = {
			if = {
				limit = {
					scope:grumpy_liege = {
						can_start_scheme = {
							type = murder
							target_character = scope:inspiration_owner
						}
					}
				}
				scope:grumpy_liege = {
					start_scheme = {
						type = murder
						target_character = scope:inspiration_owner
					}
				}
			}
		}
		scope:grumpy_liege = {
			add_opinion = {
				target = root
				modifier = insulted_opinion
				opinion = -25
			}
		}
		scope:inspiration_owner = {
			if = {
				limit = { has_trait = brave }
				remove_trait = brave
				add_trait = craven
			}
			else_if = {
				limit = { has_trait = trusting }
				remove_trait = trusting
				add_trait = paranoid
			}
			change_artifact_quality_effect = {
				AMOUNT = -2
			}
		}
		if = {
			limit = {
				scope:inspiration_owner = {
					can_start_scheme = {
						type = murder
						target_character = scope:grumpy_liege
					}
				}
			}
			scope:inspiration_owner = {
				start_scheme = {
					type = murder
					target_character = scope:grumpy_liege
				}
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 0.1
				ai_boldness = 0.1
			}
		}
	}

	option = { #help the slighted adventurer scheme 
		name = fund_inspiration.6507.b
		trigger = {
			scope:grumpy_liege = {
				is_vassal_or_below_of = root
			}
			can_start_scheme = {
				type = murder
				target_character = scope:grumpy_liege
			}
		}
		start_scheme = {
			type = murder
			target_character = scope:grumpy_liege
		}
		random_scheme = {
			limit = {
				scheme_type = murder
				scheme_target_character = scope:grumpy_liege
			}
			save_scope_as = grumpy_liege_murder
		}
		try_to_force_assign_character_to_random_agent_slot_effect = {
			SCHEME = scope:grumpy_liege_murder
			CHAR = scope:inspiration_owner
			YEARS = 20
		}
		reverse_add_opinion = {
			target = scope:inspiration_owner
			modifier = grateful_opinion
			opinion = 40
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_boldness = 0.5
			}
		}
	}

	option = { #ignore everything and refuse to seek vengeance
		name = fund_inspiration.6507.c
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = -4
			}
			add_opinion = {
				target = root
				modifier = insulted_opinion
				opinion = -20
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_boldness = -0.5
				ai_rationality = 0.5
			}
		}
	}
}

#Adventurer studying beavers in the Taiga

fund_inspiration.6508 = {
	type = character_event
	title = fund_inspiration.6508.t
	desc = 	{
		desc = fund_inspiration.6508.introduction
		desc = fund_inspiration.6508.desc
		triggered_desc = {
			trigger = {
				employs_court_position = royal_architect_court_position
			}
			desc = fund_inspiration.6508.architect_desc
		}
	}
	theme = hunting
	override_background = {
		reference = wilderness_steppe
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}
	lower_left_portrait = {
		character = scope:royal_architect
	}
	lower_right_portrait = {
		character = scope:child
	}
	
	cooldown = { years = 15 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = taiga
			}
		}
		NOR = {
			any_character_artifact = {
				has_variable = beaver_book
			}
			any_child = {
				any_character_artifact = {
					has_variable = beaver_book
				}
			}
			any_court_position_holder = {
				type = royal_architect_court_position
				any_character_artifact = {
					has_variable = beaver_book
				}
			}
		}
	}

	immediate = {
		random_court_position_holder = {
			type = royal_architect_court_position
			save_scope_as = court_architect
		}
		scope:inspiration_owner = {
			#To stagger any following events
			add_character_flag = {
				flag = fund_adventure_inspiration_event_cooldown
				days = { 30 60 }
			}
			create_artifact = {
				name = beaver_book_name
				description = beaver_book_description
				type = miscellaneous
				visuals = book
				modifier = artifact_build_time_2_modifier
				save_scope_as = beaver_book
				history = {
					type = created
					actor = scope:inspiration_owner
					recipient = root
					location = scope:inspiration_owner.location
				}
			}
			hidden_effect_new_object = {
				scope:beaver_book = {
					flag_as_trash_artifact = yes
					set_variable = {
						name = beaver_book
						value = yes
					}
				}
			}
			add_learning_skill = 2
		}
		random_child = {
			limit = {
				age < 15
				is_available_ai = yes
			}
			save_scope_as = child
		}
	}
	option = { #study the beaver book yourself
		name = fund_inspiration.6508.a
		add_stewardship_lifestyle_xp = massive_lifestyle_xp
		scope:beaver_book = {
			set_owner = root
		}
	}

	option = { #give the book to your architect to study
		name = fund_inspiration.6508.b
		trigger = { exists = scope:court_architect }
		custom_tooltip = fund_inspiration.6508.b.tt
		scope:court_architect = {
			add_stewardship_skill = 2
			set_variable = {
				name = fund_inspiration_6508_architect_improvement
				value = yes
			}
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 20
			}
		}
		scope:beaver_book = {
			set_owner = scope:court_architect
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = { #give the book to your child for fun
		name = fund_inspiration.6508.c
		trigger = {
			exists = scope:child
		}
		scope:child = {
			add_stewardship_skill = 2
			add_opinion = {
				target = root
				modifier = supportive_parent
				opinion = 20
			}
		}
		scope:beaver_book = {
			set_owner = scope:child
		}
		if = {
			limit = { exists = scope:court_architect }
			scope:court_architect = {
				add_opinion = {
					target = root
					modifier = insulted_opinion
					opinion = -20
				}
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = -0.2
				ai_compassion = 0.5
			}
		}
	}
	option = { #pay to encourage the adventurer to keep up good work
		name = fund_inspiration.6508.d
		trigger = {
			NAND = {
				any_child = {
					age < 15
					is_available_ai = yes
				}
				employs_court_position = royal_architect_court_position
			}
		}
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = 2
			}
			add_opinion = {
				target = root
				modifier = grateful_opinion
				opinion = 10
			}
		}
		remove_short_term_gold = minor_gold_value
		scope:beaver_book = {
			set_owner = root
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = -0.5
			}
			modifier = {
				short_term_gold < minor_gold_value
				factor = 0
			}
		}
	}
}

#Adventurer vastly exaggerating what crocodiles look like

fund_inspiration.6509 = {
	type = character_event
	title = fund_inspiration.6509.t
	desc = {
		desc = fund_inspiration.6509.intro_desc
		desc = fund_inspiration.6509.desc
	}
	theme = hunting
	override_background = {
		reference = wilderness_steppe
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}
	
	cooldown = { years = 10 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = floodplains
			}
		}
		NOT = {
			any_character_artifact = {
				has_variable = crocodile_tapestry
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		
	}

	option = { #make a crocodile tapestry and display it! the horror!
		name = fund_inspiration.6509.a
		remove_short_term_gold = medium_gold_value

		save_scope_as = owner
		set_artifact_rarity_common = yes
			create_artifact = {
				name = crocodile_tapestry_name
				description = crocodile_tapestry_description
				type = tapestry
				visuals = tapestry
				modifier = artifact_dread_gain_mult_1_modifier
				wealth = scope:wealth
				quality = scope:quality
				save_scope_as = crocodile_tapestry
				history = {
					type = given
					actor = scope:inspiration_owner
					recipient = root
					location = scope:inspiration_owner.location
				}
			}
			hidden_effect_new_object = {
				scope:crocodile_tapestry = {
					flag_as_trash_artifact = yes
					set_variable = {
						name = crocodile_tapestry
						value = yes
					}
				}
			}
		
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.5
			}
			modifier = {
				short_term_gold < medium_gold_value
				factor = 0
			}
		}
	}

	option = { #be afraid of the crocodile, but impressed by the adventurer
		name = fund_inspiration.6509.b
		add_stress = minor_stress_gain
		scope:inspiration_owner = {
			change_artifact_quality_effect = {
				AMOUNT = 2
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_rationality = -0.1
			}
		}
	}

	option = { #you know what crocodiles are, see em everyday
		name = fund_inspiration.6509.c
		trigger = {
			any_held_title = {
				this = title:k_egypt
			}
		}
		add_learning_lifestyle_xp = medium_lifestyle_xp
		add_prestige = medium_prestige_gain

		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}
}

#Adventurer meeting a vigilante band who hide in the forest

fund_inspiration.6510 = {
	type = character_event
	title = fund_inspiration.6510.t
	desc = {
		desc = fund_inspiration.6510.intro_desc
		desc = fund_inspiration.6510.desc
	}
	theme = hunting
	override_background = {
		reference = wilderness_forest
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	trigger = {
		exists = scope:inspiration_owner.location.barony.holder
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = forest
			}
			NOT = { has_trait = greedy }
			NOT = { is_councillor_of = root }
		} 
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:inspiration_owner = {
			location = {
				this.barony.holder = { save_scope_as = enemy_liege }
			}
			add_trait = improvident
		}

	}

	option = { #make them your steward, they become good at understanding the people
		name = fund_inspiration.6510.a
		
		trigger = {
			scope:inspiration_owner = {
				can_be_steward_trigger = { COURT_OWNER = root }
			}
		}
		
		root = { fire_councillor = cp:councillor_steward }
		root = {
			assign_councillor_type = {
				type = councillor_steward
				target = scope:inspiration_owner
			}
		}
		scope:inspiration_owner = {
			add_trait = peasant_leader
		}
		hidden_effect = {
			end_inspiration_sponsorship = scope:inspiration
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_rationality = 0.5
			}
		}
	}

	option = { #threaten to kill the adventurer for not returning
		name = fund_inspiration.6510.b
		duel = {
			skill = intrigue
			target = scope:inspiration_owner
			10 = {
				custom_tooltip = fund_inspiration.6510.b.toast_outcome.positive
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				send_interface_toast = {
					title = fund_inspiration.6510.b.toast_outcome.positive
					custom_tooltip = fund_inspiration.6510.b.toast_outcome.positive.continue
					left_icon = root
					scope:inspiration_owner = {
						change_artifact_quality_effect = { AMOUNT = 2 }
					}
				}
			}
			20 = {
				custom_tooltip = fund_inspiration.6510.b.toast_outcome.refusal
				send_interface_toast = {
					title = fund_inspiration.6510.b.toast_outcome.refusal
					custom_tooltip = fund_inspiration.6510.b.toast_outcome.positive.flee
					left_icon = root
					scope:inspiration_owner = {
						end_inspiration_sponsorship = scope:inspiration
						add_prestige = medium_prestige_loss
						hidden_effect = {
							death = { death_reason = death_vanished }
						}
					}
				}
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_boldness = 0.5
			}
		}
	}

	option = { # let em go, you don't need em
		name = fund_inspiration.6510.c
		end_inspiration_sponsorship = scope:inspiration
		scope:inspiration_owner = {
			hidden_effect = {
				death = { death_reason = death_vanished }
			}
		}
		ai_chance = {
			base = 10
		}
	}
}

#Ageing or sick adventurer decides that the mountains are a last moment of beauty for them

fund_inspiration.6511 = {
	type = character_event
	title = fund_inspiration.6511.t
	desc = {
		desc = fund_inspiration.6511.intro_desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = {
						age > 60
					}
				}
				desc = fund_inspiration.6511.old_age
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = {
						health <= poor_health
					}
				}
				desc = fund_inspiration.6511.poor_health
			}
			triggered_desc = {
				trigger = {
					scope:inspiration_owner = {
						location = {
							has_province_modifier = winter_harsh_modifier
						}
					}
				}
				desc = fund_inspiration.6511.winter
			}
		}
	}
	theme = death
	override_background = {
		reference = wilderness_mountains
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	cooldown = { years = 15 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = mountains
			}
			OR = {
				age > 60
				health <= poor_health
				OR = {
					location = {
						has_province_modifier = winter_harsh_modifier
					}
				}
			}
		}
	}

	weight_multiplier = {
		base = 0.5
	}

	immediate = {
		scope:inspiration_owner = {
			death = {
				death_reason = death_ice
			}
		}
	}

	option = { #these are conditions under which the adventurer can have a dramatic death, they aren't really there for you to select anything, just to tell you you were foolish for sending them into the snowy mountains
		name = fund_inspiration.6511.a
		#This event just informs you it has happened
	}
}

#Adventurer asking you to name the mountain

fund_inspiration.6512 = {
	type = character_event
	title = fund_inspiration.6512.t
	desc = {
		desc = fund_inspiration.6512.intro_desc
		desc = fund_inspiration.6512.desc
	}
	theme = hunting
	override_background = {
		reference = wilderness_mountains
	}

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}


	
	cooldown = { years = 10 }

	trigger = {
		scope:inspiration = {
			has_inspiration_type = adventure_inspiration
		}
		scope:inspiration_owner = {
			location = {
				terrain = desert_mountains
				this.county.holder = {
					NOR = {
						this.top_liege = root
						this.liege = root
						this = root
					}
				}
			}
		}
		NOT = {
			any_character_artifact = {
				has_variable = mountain_rock
			}
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		scope:inspiration_owner = {
			location = {
				save_scope_as = mountain_location
			}
			hidden_effect = {	
				create_artifact = {
					name = mountain_rock_name
					description = mountain_rock_description
					type = miscellaneous
					visuals = rock
					modifier = artifact_heavy_cavalry_toughness_1_modifier
					save_scope_as = mountain_rock
					history = {
						type = discovered
						actor = scope:inspiration_owner
						recipient = root
						location = scope:inspiration_owner.location
					}
				}
				hidden_effect_new_object = {
					scope:mountain_rock = {
						flag_as_trash_artifact = yes
						set_variable = {
							name = mountain_rock
							value = yes
						}
					}
				}
			}
		}
		if = {
			limit = {
				any_relation = { type = lover }
			}
			random_relation = {
				type = lover
				save_scope_as = lover
			}
		}
		if = {
			limit = {
				any_relation = { type = potential_rival }
			}
			random_relation = {
				type = potential_rival
				save_scope_as = rival
			}
		}
	}

	after = {
		if = {
			limit = {
				NOT = { has_character_flag = got_mountain_rock }
			}
			destroy_artifact = scope:mountain_rock
		}
		remove_character_flag = got_mountain_rock
	}

	option = { #scoff at the idea of not respecting the local name
		name = fund_inspiration.6512.a
		add_prestige = medium_prestige_gain
		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = { #dig at the rocky mountains
		name = fund_inspiration.6512.b
		trigger = {
			NOR = {
				exists = scope:lover
				is_cannibal_trigger = yes
				is_male = yes
				exists = scope:rival
				has_trait = greedy
				martial > 10
				intrigue > 10
			}
		}
		every_courtier_or_guest = {
			limit = { age < 14 }
			custom = custom.every_child_in_the_court
			add_opinion = {
				modifier = humorous_opinion
				opinion = 10
				target = root
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
	}

	option = { #name after your war god
		name = fund_inspiration.6512.c
		trigger = {
			martial > 10
			NOR = {
				exists = scope:lover
				is_cannibal_trigger = yes
				is_male = yes
				exists = scope:rival
				has_trait = greedy
				intrigue > 10
			}
		}
		skill = martial
		add_martial_skill = 1
		add_piety = minor_piety_gain
		stress_impact = {
			arrogant = minor_stress_impact_gain
			cynical = medium_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}

	option = { #name after your fate god
		name = fund_inspiration.6512.d
		trigger = {
			intrigue > 10
			NOR = {
				exists = scope:lover
				is_cannibal_trigger = yes
				is_male = yes
				exists = scope:rival
				has_trait = greedy
				martial > 10
			}
		}
		skill = intrigue
		add_intrigue_skill = 1
		add_piety = minor_piety_gain
		stress_impact = {
			arrogant = minor_stress_impact_gain
			cynical = medium_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = { #name after your beloved and become their soulmate, possibly
		name = fund_inspiration.6512.e
		trigger = { exists = scope:lover }
		if = {
			limit = {
				can_set_relation_soulmate_trigger = { CHARACTER = scope:lover }
			}
			set_relation_soulmate = { reason = soulmate_named_mountain copy_reason = lover target = scope:lover }
		}
		else = {
			reverse_add_opinion = {
				target = scope:lover
				opinion = 20
				modifier = love_opinion
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
			callous = medium_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_compassion = 0.5
			}
		}
	}

	option = { #flex that you like biting things
		name = fund_inspiration.6512.f
		trigger = { is_cannibal_trigger = yes }
		trait = cannibal
		add_dread = medium_dread_gain
		stress_impact = {
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = -0.5
			}
		}
		
	}

	option = { #name after your... ahem... rod
		name = fund_inspiration.6512.g
		trigger = {
			is_male = yes
			has_trait = arrogant
		}
		add_character_modifier = {
			modifier = phallic_mountain_modifier
			years = 10
		}
		stress_impact = {
			arrogant = minor_stress_impact_loss
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.7
			}
		}
	}

	option = { #name after your rival. that will teach them!
		name = fund_inspiration.6512.h
		trigger = { exists = scope:rival }
		progress_towards_rival_effect = {
			REASON = rival_name_inspiration
			CHARACTER = scope:rival
			OPINION = 0
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 0.5
			}
		}
	}

	option = { #force them to lug some rocks home
		name = fund_inspiration.6512.i
		trigger = { has_trait = greedy }
		trait = greedy
		scope:mountain_rock = { set_owner = root }
		add_character_flag = got_mountain_rock
		stress_impact = {
			content = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = 0.5
				ai_rationality = 0.5
			}
		}
	}
}

####################
# Alchemist

# Alchemy (Metal) - what subtype?
# by Linnéa Thimrén
fund_inspiration.8001 = {
	type = character_event
	title = fund_inspiration.8001.t
	desc = fund_inspiration.8001.desc
	theme = realm
	left_portrait = {
		character = scope:inspiration_owner
		animation = personality_rational
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			has_inspiration_type = alchemy_inspiration
			inspiration_owner = { #They have already decided what to write about
				is_available_ai_adult = yes
				exists = var:artifact_alchemy_type
				var:artifact_alchemy_type = flag:alchemy_type_metals
				NOR = { #These flags are set on the inspiration owner since the sponsor might be sponsoring multiple inspirations at once
					exists = var:artifact_alchemy_type_metal_subtype
					has_character_flag = had_event_fund_inspiration_8001
					has_character_flag = fund_alchemy_inspiration_event_cooldown
				}
			}
		}
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
		scope:inspiration_owner = {
			# Very long time-out added since we don't want to risk this triggering again. The flag is removed in the completion effect
			add_character_flag = {
				flag = had_event_fund_inspiration_8001
				years = 20
			}

			#To stagger any following events
			add_character_flag = {
				flag = fund_alchemy_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
	}

	#Gold
	option = {
		name = fund_inspiration.8001.a
		custom_tooltip = fund_inspiration.8001.a.tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_alchemy_type_metal_subtype
				value = flag:gold
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = 0.5
				ai_boldness = 0.25
			}
		}
	}

	#Silver
	option = {
		name = fund_inspiration.8001.b
		custom_tooltip = fund_inspiration.8001.b.tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_alchemy_type_metal_subtype
				value = flag:silver
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = 0.5
				ai_rationality = 0.25
			}
		}
	}

	#Mercury
	option = {
		name = fund_inspiration.8001.c
		custom_tooltip = fund_inspiration.8001.c.tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_alchemy_type_metal_subtype
				value = flag:mercury
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	#Arsenic
	option = {
		name = fund_inspiration.8001.d
		custom_tooltip = fund_inspiration.8001.d.tt
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_alchemy_type_metal_subtype
				value = flag:arsenic
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_compassion = -0.5
			}
		}
	}
}


# Get poisoned by a bad alchemist
# by Linnéa Thimrén
fund_inspiration.8011 = {
	type = character_event
	title = fund_inspiration.8011.t
	desc = fund_inspiration.8011.desc
	theme = learning_medicine_focus
	left_portrait = scope:inspiration_owner
	
	cooldown = { days = 1825 }

	trigger = {
		scope:inspiration = { has_inspiration_type = alchemy_inspiration }
		scope:inspiration_owner = {
			NOT = {  has_character_flag = had_event_fund_inspiration_8011 }
			has_no_inspiration_event_cooldown = yes
			exists = var:artifact_alchemy_type
			OR = {
				var:artifact_alchemy_type = flag:alchemy_type_panacea
				var:artifact_alchemy_type = flag:alchemy_type_immortality
			}
		}
	}

	weight_multiplier = {
		base = 0.1

		modifier = { #More likely if they're not that bright
			add = 0.75
			scope:inspiration_owner = {
				has_trait = intellect_bad
			}
		}
	}

	immediate = {
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_8011
				years = 5
			}

			#To stagger any following events
			add_character_flag = {
				flag = fund_alchemy_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		add_character_modifier = { #Literally poisoned by gold...
			modifier = poisonous_gold_modifier
			years = 2
		}
	}

	option = { #Forgive
		name = fund_inspiration.8011.a
		if = { #To make sure that the inspiration hasn't been removed
			limit = {
				exists = scope:inspiration
			}
			scope:inspiration_owner = {
				change_artifact_quality_effect = {
					AMOUNT = 4
				}
				add_opinion = {
					target = root
					modifier = kindness_opinion
					opinion = 20
				}
			}
		}
		stress_impact = {
			forgiving = medium_stress_impact_loss
			wrathful = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = forgiving
			}
			ai_value_modifier = {
				ai_vengefulness = -0.5
				ai_compassion = 0.5
			}
		}
	}

	option = { #Imprison
		name = fund_inspiration.8011.b
		if = {
			limit = { exists = scope:inspiration }
			end_inspiration_sponsorship = scope:inspiration
		}
		rightfully_imprison_character_effect = {
			TARGET = scope:inspiration_owner
			IMPRISONER = root
		}
		hidden_effect = { #To make sure we threw them in the dungeon
			scope:inspiration_owner = {
				if = {
					limit = {
						NOT = { is_in_prison_type = dungeon }
					}
					change_prison_type = dungeon
				}
			}
		}
		stress_impact = {
			wrathful = medium_stress_impact_loss
			forgiving = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = vengeful
			}
			ai_value_modifier = {
				ai_vengefulness = 0.5
				ai_compassion = -0.25
			}
		}
	}

	option = { #Execute
		name = fund_inspiration.8011.c
		hidden_effect = {
			if = {
				limit = { exists = scope:inspiration }
				end_inspiration_sponsorship = scope:inspiration
			}
		}
		scope:inspiration_owner = {
			death = { death_reason = death_execution killer = root }
		}
		execute_opinion_effect = { VICTIM = scope:inspiration_owner EXECUTIONER = root }
		stress_impact = {
			wrathful = medium_stress_impact_loss
			sadistic = medium_stress_impact_loss
			forgiving = medium_stress_impact_gain
			compassionate = major_stress_impact_gain
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 50
				has_trait = vengeful
			}
			ai_value_modifier = {
				ai_vengefulness = 0.75
				ai_compassion = -0.5
			}
		}
	}
}

# Church disproves of you employing an alchemist
# by Linnéa Thimrén
fund_inspiration.8012 = {
	type = character_event
	title = fund_inspiration.8012.t
	desc = fund_inspiration.8012.desc
	theme = learning_medicine_focus
	left_portrait = scope:inspiration_owner
	right_portrait = {
		character = scope:court_chaplain
		animation = anger
	}
		
	trigger = {
		scope:inspiration = { has_inspiration_type = alchemy_inspiration }
		scope:inspiration_owner = {
			NOT = {  has_character_flag = had_event_fund_inspiration_8012 }
			has_no_inspiration_event_cooldown = yes
		}
		religion = religion:christianity_religion #Basically the Christian church were the only ones complaining about this
		exists = cp:councillor_court_chaplain
		cp:councillor_court_chaplain = { is_physically_able_adult = yes }
	}

	weight_multiplier = {
		base = 1
		modifier = { #Less likely to fire if the alchemist is zealous
			add = -0.75
			scope:inspiration_owner = {
				has_trait = zealous
			}
		}
	}
	
	immediate = {
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_8012
				years = 5
			}

			#To stagger any following events
			add_character_flag = {
				flag = fund_alchemy_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		cp:councillor_court_chaplain = { save_scope_as = court_chaplain }
	}

	option = { # Fire them
		name = fund_inspiration.8012.a
		if = {
			limit = { exists = scope:inspiration }
			end_inspiration_sponsorship = scope:inspiration
		}
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = hate_opinion
				opinion = -30
			}
			banish = yes # banish_effect not used for unlanded
		}
		add_piety = minor_piety_gain
		scope:court_chaplain = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 30
			}
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_zeal = 0.75
			}
		}
	}

	option = { # Convince the chaplain that it's fine
		name = fund_inspiration.8012.b
		trigger = {
			diplomacy >= high_skill_rating
		}
		show_as_unavailable = {
			diplomacy < high_skill_rating
		}
		duel = {
			skill = diplomacy
			value = 8
			40 = {
				desc = fund_inspiration.8012.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 0.5
				}
				send_interface_toast = {
					title = fund_inspiration.8012.b.success
					left_icon = scope:court_chaplain
					add_character_modifier = {
						modifier = inspiration_alchemy_condoned_by_church_modifier
						years = 5
					}
				}
			}
			10 = {
				desc = fund_inspiration.8012.b.failure
				send_interface_toast = {
					title = fund_inspiration.8012.b.failure
					left_icon = scope:court_chaplain
					scope:court_chaplain = {
						add_opinion = {
							target = root
							modifier = impious_opinion
							opinion = -20
						}
					}
				}
			}
		}
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = pleased_opinion
				opinion = 15
			}
		}
		ai_chance = {
			base = 100
		}
	}

	option = { # No!
		name = fund_inspiration.8012.c
		add_piety = medium_piety_loss
		scope:court_chaplain = {
			add_opinion = {
				target = root
				modifier = refusal_opinion
				opinion = -20
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = 0.5
			}
		}
	}
}

# Find a book from famous alchemist Jabir ibn Hayyan from the Islamic Golden Age
# by Linnéa Thimrén
fund_inspiration.8013 = {
	type = character_event
	title = fund_inspiration.8013.t
	desc = fund_inspiration.8013.desc
	theme = learning_medicine_focus
	right_portrait = scope:inspiration_owner
	artifact = { # To display the artifact in the event-window
		target = scope:newly_created_artifact
		position = lower_center_portrait
	}
	
	cooldown = { days = 1825 }
	
	trigger = {
		scope:inspiration = { has_inspiration_type = alchemy_inspiration }
		scope:inspiration_owner = {
			NOT = {  has_character_flag = had_event_fund_inspiration_8013 }
			has_no_inspiration_event_cooldown = yes
		}
		current_date >= 900.1.1 #Jabir didn't start being mentioned until around here
		is_ai = no #Only for players so we don't have too many books lying around
	}

	weight_multiplier = {
		base = 0.25
		modifier = {
			add = 1
			culture = { has_cultural_pillar = heritage_arabic }
		}
	}
	
	immediate = {
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_8013
				years = 5
			}

			#To stagger any following events
			add_character_flag = {
				flag = fund_alchemy_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		random_held_title = {
			limit = { tier = tier_county }
			random_county_province = {
				limit = { has_holding = yes }
				save_scope_as = barony_market
			}
		}
		hidden_effect = {
			random_dummy_gender_effect = yes #Since the author will not be set
			random_list = { #To create one of Jabir ibn Hayyan's books
				10 = {
					create_artifact_book_effect = {
						OWNER = root
						CREATOR = scope:dummy_gender
						SET_SUBJECT = flag:alchemy
						SET_TOPIC = flag:the_great_book_of_mercy
					}
				}
				10 = {
					create_artifact_book_effect = {
						OWNER = root
						CREATOR = scope:dummy_gender
						SET_SUBJECT = flag:alchemy
						SET_TOPIC = flag:the_book_of_seventy
					}
				}
			}
		}
	}

	option = { #Study it
		name = fund_inspiration.8013.a
		custom_tooltip = fund_inspiration.8013.a_tt
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = disappointed_opinion
				opinion = -10
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				OR = {
					has_trait = scholar
 					has_lifestyle = learning_lifestyle
				}
			}
			ai_value_modifier = {
				ai_greed = -0.25
			}
		}
	}

	option = { #Give it to alchemist
		name = fund_inspiration.8013.b
		custom_tooltip = fund_inspiration.8013.b_tt
		if = { #To make sure that the inspiration hasn't been removed
			limit = {
				exists = scope:inspiration
			}
			scope:inspiration_owner = {
				change_artifact_quality_effect = {
					AMOUNT = 4
				}
				add_opinion = {
					target = root
					modifier = grateful_opinion
					opinion = 40
				}
				progress_towards_friend_effect = {
					CHARACTER = root
					OPINION = 0
					REASON = friend_given_book
				}
			}
		}
		hidden_effect = {
			scope:newly_created_artifact = {
				set_owner = {
					target = scope:inspiration_owner
					history = {
						location = root.capital_province
						actor = root
						recipient = scope:inspiration_owner
						type = given
					}
				}
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = -0.25
				ai_compassion = 0.25
			}
		}
	}

	option = { #Sell it
		name = fund_inspiration.8013.c
		hidden_effect = { destroy_artifact = scope:newly_created_artifact }
		add_gold = medium_gold_value
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -15
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = 0.5
			}
			modifier = {
				gold < 0
				add = 100
			}
		}
	}

	after = {
		#To clean up variables set when creating the book
		if = {
			limit = { has_variable = book_artifact_subject }
			remove_variable = book_artifact_subject
		}
		if = {
			limit = { has_variable = book_artifact_topic }
			remove_variable = book_artifact_topic
		}
		if = {
			limit = { has_variable = quality }
			remove_variable = quality
		}
		if = {
			limit = { has_variable = wealth }
			remove_variable = wealth
		}
	}
}

# Alchemist never produces anything, just _thinks_ and ponders reality and the nature of matter
# by Linnéa Thimrén
fund_inspiration.8014 = {
	type = character_event
	title = fund_inspiration.8014.t
	desc = fund_inspiration.8014.desc
	theme = learning_medicine_focus
	left_portrait = scope:inspiration_owner
	
	cooldown = { days = 1825 }
	
	trigger = {
		scope:inspiration = { has_inspiration_type = alchemy_inspiration }
		scope:inspiration_owner = {
			NOT = {  has_character_flag = had_event_fund_inspiration_8014 }
			has_no_inspiration_event_cooldown = yes
		}
	}

	weight_multiplier = {
		base = 0.5

		modifier = { #More likely if they're not that bright
			add = 1
			scope:inspiration_owner = {
				has_trait = intellect_bad
			}
		}
	}
	
	immediate = {
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_8014
				years = 5
			}

			#To stagger any following events
			add_character_flag = {
				flag = fund_alchemy_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
	}

	option = { #Get to work!!
		name = fund_inspiration.8014.a
		if = { #To make sure that the inspiration hasn't been removed
			limit = {
				exists = scope:inspiration
			}
			scope:inspiration_owner = {
				change_artifact_quality_effect = {
					AMOUNT = -2
				}
			}
		}
		stress_impact = {
			impatient = minor_stress_impact_loss
			patient = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = impatient
			}
			ai_value_modifier = {
				ai_energy = 0.5
			}
		}
	}

	option = { #Take your time
		name = fund_inspiration.8014.b
		if = { #To make sure that the inspiration hasn't been removed
			limit = {
				exists = scope:inspiration
			}
			scope:inspiration_owner = {
				change_artifact_quality_effect = {
					AMOUNT = 2
				}
			}
			scope:inspiration = {
				change_inspiration_progress = -3
			}
		}
		stress_impact = {
			impatient = medium_stress_impact_gain
			patient = minor_stress_impact_loss
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = patient
			}
			ai_value_modifier = {
				ai_rationality = 0.5
			}
		}
	}

	option = { #Fire them
		name = fund_inspiration.8014.c
		custom_tooltip = fund_inspiration.8014.c.tt
		add_gold = medium_gold_value
		end_inspiration_sponsorship = scope:inspiration
		#To clean out flags and stuff
		inspiration_completion_effect = yes
		stress_impact = {
			compassionate = medium_stress_impact_gain
			wrathful = medium_stress_impact_loss
		}
		ai_chance = {
			base = 0
		}
	}
}


# Plead with alchemist to resurrect family member/friend
# by Linnéa Thimrén
fund_inspiration.8015 = {
	type = character_event
	title = fund_inspiration.8015.t
	desc = fund_inspiration.8015.desc
	theme = learning_medicine_focus
	left_portrait = scope:inspiration_owner
	right_portrait = scope:loved_one
	
	cooldown = { days = 1825 }
	
	trigger = {
		scope:inspiration = { has_inspiration_type = alchemy_inspiration }
		NOT = { has_trait = callous }
		OR = { #Someone you cared about a lot has died
			exists = var:mourning_parent
			exists = var:mourning_soulmate
			exists = var:mourning_friend
		}
		scope:inspiration_owner = {
			NOT = {  has_character_flag = had_event_fund_inspiration_8015 }
			has_no_inspiration_event_cooldown = yes
		}
	}

	weight_multiplier = {
		base = 1
		compare_modifier = {
			value = ai_rationality
			multiplier = -0.1
		}
		modifier = {
			add = -0.75
			has_trait = zealous
		}
	}
	
	immediate = {
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_8015
				years = 10
			}

			#To stagger any following events
			add_character_flag = {
				flag = fund_alchemy_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		if = {
			limit = {
				exists = var:mourning_parent
			}
			var:mourning_parent = { save_scope_as = loved_one }
		}
		else_if = {
			limit = {
				exists = var:mourning_soulmate
			}
			var:mourning_soulmate = { save_scope_as = loved_one }
		}
		else_if = {
			limit = {
				exists = var:mourning_friend
			}
			var:mourning_friend = { save_scope_as = loved_one }
		}
	}

	option = { #Talk instead
		name = fund_inspiration.8015.a
		add_stress = medium_stress_loss
		stress_impact = {
			arrogant = medium_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
			}
		}
	}

	option = { #Demand it!
		name = fund_inspiration.8015.b
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -15
			}
		}
		custom_tooltip = fund_inspiration.8015.b.tt
		trigger_event = {
			id = fund_inspiration.8016
			days = { 3 7 }
		}
		stress_impact = {
			gregarious = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 50
				has_trait = arrogant
			}
			ai_value_modifier = {
				ai_rationality = -0.25
				ai_boldness = 0.25
			}
		}
	}
}


# Follow-up event
# by Linnéa Thimrén
fund_inspiration.8016 = {
	type = character_event
	title = fund_inspiration.8015.t
	desc = fund_inspiration.8016.desc
	theme = learning_medicine_focus
	left_portrait = scope:inspiration_owner
	right_portrait = scope:loved_one
		
	trigger = {
		exists = scope:inspiration
		scope:inspiration = { has_inspiration_type = alchemy_inspiration }
		exists = scope:inspiration_owner
		scope:inspiration_owner = {
			is_physically_able = yes
		}
		exists = scope:loved_one
	}
	
	immediate = {
		add_stress = medium_stress_gain
	}

	option = { #Ugh
		name = fund_inspiration.8016.a
		stress_impact = {
			arrogant = medium_stress_impact_gain
			shy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
			}
		}
	}

	option = { #Imprison them
		name = fund_inspiration.8016.b
		rightfully_imprison_character_effect = {
			TARGET = scope:inspiration_owner
			IMPRISONER = root
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 50
				has_trait = wrathful
			}
			ai_value_modifier = {
				ai_rationality = -0.25
				ai_boldness = 0.25
			}
		}
	}
}


# Helping the court tutor
# by Linnéa Thimrén
scripted_trigger fund_inspiration_8017_court_tutor_scripted_trigger= {
	is_available_ai_adult = yes
	NOT = { has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:inspiration_owner } }
}

fund_inspiration.8017 = {
	type = character_event
	title = fund_inspiration.8017.t
	desc = fund_inspiration.8017.desc
	theme = learning_medicine_focus
	left_portrait = scope:inspiration_owner
	right_portrait = scope:court_tutor
	
	cooldown = { days = 1825 }
	
	trigger = {
		scope:inspiration = { has_inspiration_type = alchemy_inspiration }
		scope:inspiration_owner = {
			NOT = {  has_character_flag = had_event_fund_inspiration_8017 }
			has_no_inspiration_event_cooldown = yes
		}
		employs_court_position = court_tutor_court_position
		any_court_position_holder = {
			type = court_tutor_court_position
			fund_inspiration_8017_court_tutor_scripted_trigger = yes
		}
	}
	
	immediate = {
		scope:inspiration_owner = {
			add_character_flag = {
				flag = had_event_fund_inspiration_8017
				years = 10
			}
			#To stagger any following events
			add_character_flag = {
				flag = fund_alchemy_inspiration_event_cooldown
				days = { 30 60 }
			}
		}
		random_court_position_holder = {
			type = court_tutor_court_position
			limit = {
				fund_inspiration_8017_court_tutor_scripted_trigger = yes
			}
			save_scope_as = court_tutor
		}
	}

	option = { # Encourage them
		name = fund_inspiration.8017.a
		scope:court_tutor = {
			add_learning_skill = 1
			progress_towards_friend_effect = {
				CHARACTER = scope:inspiration_owner
				OPINION = 0
				REASON = friend_shared_knowledge
			}
		}
		stress_impact = {
			compassionate = minor_stress_impact_loss
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_vengefulness = -0.25
			}
		}
	}

	option = { # Back to work!!
		name = fund_inspiration.8017.b
		scope:inspiration_owner = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -15
			}
		}
		scope:court_tutor = {
			add_opinion = {
				target = root
				modifier = respect_opinion
				opinion = -15
			}
		}
		if = { #To make sure that the inspiration hasn't been removed
			limit = {
				exists = scope:inspiration
			}
			scope:inspiration_owner = {
				change_artifact_quality_effect = {
					AMOUNT = 2
				}
			}
		}
		stress_impact = {
			compassionate = medium_stress_impact_gain
			wrathful = medium_stress_impact_loss
			diligent = minor_stress_impact_loss
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_greed = 0.5
				ai_rationality = -0.2
				ai_boldness = 0.2
			}
		}
	}
}


# Add a dedication
# by Claudia Baldassi

fund_inspiration.7001 = {
	type = character_event
	title = fund_inspiration.7001.t
	desc = fund_inspiration.7001.desc
	theme = realm

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	right_portrait = { 
		character = root
		animation = happiness
	}

	lower_left_portrait = scope:dedication_a
	lower_center_portrait = scope:dedication_b

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			NOR = { 
				has_variable = inspiration_dedication_var
				has_variable = inspiration_mod_choice_var
				has_inspiration_type = adventure_inspiration
				has_inspiration_type = alchemy_inspiration
				inspiration_owner = { has_variable = banner_commission }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			exists = primary_spouse
			add = 1
		}
		modifier = {
			any_close_family_member = {
				only_if_dead = yes
				days_since_death <= 365
			}
			add = 1
		}
	}

	immediate = {
		scope:inspiration = {
			set_variable = inspiration_dedication_var
		}		
		if = {
			limit = {
				exists = primary_spouse
				primary_spouse = {
					NOR = {
						has_relation_rival = root
						has_relation_nemesis = root
					}
				}
			}
			primary_spouse = {
				save_scope_as = dedication_a
			}
		}
		if = {
			limit = {
				any_close_family_member = {
					only_if_dead = yes
					days_since_death <= 365
				}
			}
			random_close_family_member = {
				only_if_dead = yes
				limit = {
					days_since_death <= 365
				}
				save_scope_as = dedication_b
			}
		}
	}

	#Option A: spouse
	option = {
		name = fund_inspiration.7001.a
		trigger = {
			exists = scope:dedication_a
		}
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_dedication_a_var
				value = scope:dedication_a
			}
		}
		reverse_add_opinion = {
			target = scope:dedication_a
			modifier = grateful_opinion
			opinion = 40
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = family_first
				add = 100
			}
			modifier = {
				has_trait = gregarious
				add = 50
			}
			modifier = {
				has_focus = intrigue_temptation_focus
				add = 50
			}
			modifier = {
				scope:dedication_a = { has_any_bad_relationship_with_root_trigger = yes }
				add = -100
			}
		}
	}

	#Option B: dead relative
	option = {
		name = fund_inspiration.7001.b
		trigger = {
			exists = scope:dedication_b
		}
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_dedication_b_var
				value = scope:dedication_b
			}
		}
		dynasty = { add_dynasty_prestige = medium_dynasty_prestige_gain }
		ai_chance = {
			base = 100
		}
	}
	
	#Option C: God
	option = {
		name = fund_inspiration.7001.c
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_dedication_var
				value = flag:dedication_c
			}
		}
		add_piety = major_piety_gain
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 1
			}
		}
	}

	#Option D: no one
	option = {
		name = fund_inspiration.7001.d
		add_prestige = medium_prestige_gain
		ai_chance = {
			base = 80
		}
	}
}

fund_inspiration.7002 = {
	type = character_event
	title = fund_inspiration.7001.t
	desc = fund_inspiration.7001.desc
	theme = realm

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	right_portrait = { 
		character = root
		animation = happiness
	}

	lower_left_portrait = scope:dedication_a
	lower_center_portrait = scope:dedication_b
	lower_right_portrait = scope:dedication_d

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			NOR = { 
				has_variable = inspiration_dedication_var
				has_variable = inspiration_mod_choice_var
				has_inspiration_type = adventure_inspiration
				has_inspiration_type = alchemy_inspiration
				inspiration_owner = { has_variable = banner_commission }
			}
		}
		OR = {
			any_relation = {
				type = lover
			}
			exists = var:mourning_soulmate
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			exists = var:mourning_soulmate
			add = 2
		}
		modifier = {
			any_relation = {
				type = lover
			}
			add = 1
		}
	}

	immediate = {
		scope:inspiration = {
			set_variable = inspiration_dedication_var
		}
		if = {
			limit = {
				any_relation = {
					type = soulmate
					NOT = {
						any_secret = {
							secret_type = secret_lover
							secret_target = root
						}
					}
				}
			}
			random_relation = {
				type = soulmate
				limit = {
					NOT = {
						any_secret = {
							secret_type = secret_lover
							secret_target = root
						}
					}
				}
				save_scope_as = dedication_a
			}
		}
		else_if = {
			limit = {
				any_relation = {
					type = lover
					NOT = {
						any_secret = {
							secret_type = secret_lover
							secret_target = root
						}
					}
				}
			}
			random_relation = {
				type = lover
				limit = {
					NOT = {
						any_secret = {
							secret_type = secret_lover
							secret_target = root
						}
					}
				}
				save_scope_as = dedication_a
			}
		}
		if = {
			limit = {
				exists = var:mourning_soulmate
			}
			var:mourning_soulmate = {
				save_scope_as = dedication_b
			}
		}
		if = {
			limit = {
				any_relation = {
					type = soulmate
					any_secret = {
						secret_type = secret_lover
						secret_target = root
					}
				}
			}
			random_relation = {
				type = soulmate
				limit = {
					any_secret = {
						secret_type = secret_lover
						secret_target = root
					}
				}
				save_scope_as = dedication_d
			}
		}
		else_if = {
			limit = {
				any_relation = {
					type = lover
					any_secret = {
						secret_type = secret_lover
						secret_target = root
					}
				}
			}
			random_relation = {
				type = lover
				limit = {
					any_secret = {
						secret_type = secret_lover
						secret_target = root
					}
				}
				save_scope_as = dedication_d
			}
		}
		if = {
			limit = {
				exists = scope:dedication_d
			}
			scope:dedication_d = {
				random_secret = {
					limit = {
						secret_type = secret_lover
						secret_target = root
					}
					save_scope_as = lover_secret
				}
			}
		}
	}

	#Option A: public soulmate/lover
	option = {
		name = fund_inspiration.7001.a
		trigger = {
			exists = scope:dedication_a
		}
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_dedication_a_var
				value = scope:dedication_a
			}
		}
		reverse_add_opinion = {
			target = scope:dedication_a
			modifier = grateful_opinion
			opinion = 40
		}
		ai_chance = {
			base = 100
			modifier = {
				has_focus = intrigue_temptation_focus
				add = 50
			}
		}
	}

	#Option B: memory of lost soulmate
	option = {
		name = fund_inspiration.7001.b
		trigger = {
			exists = scope:dedication_b
		}
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_dedication_b_var
				value = scope:dedication_b
			}
		}
		add_piety = medium_piety_gain
		ai_chance = {
			base = 125
		}
	}

	#Option C: go public with soulmate/lover
	option = {
		name = fund_inspiration.7002.c
		trigger = {
			exists = scope:dedication_d
		}
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_dedication_d_var
				value = scope:dedication_d
			}
		}
		if = {
			limit = {
				scope:dedication_d = {
					is_married = no
				}
			}
			reverse_add_opinion = {
				target = scope:dedication_d
				modifier = grateful_opinion
				opinion = 40
			}
		}
		else = {
			reverse_add_opinion = {
				target = scope:dedication_d
				modifier = angry_opinion
				opinion = -30
			}
		}
		scope:lover_secret = {
			expose_secret = root
		}
		ai_chance = {
			base = 50
			modifier = {
				has_trait = honest
				add = 100
			}
		}
	}

	#Option D: none
	option = {
		name = fund_inspiration.7001.d
		add_prestige = medium_prestige_gain
		ai_chance = {
			base = 80
		}
	}
}

fund_inspiration.7003 = {
	type = character_event
	title = fund_inspiration.7003.t
	desc = {
		desc = fund_inspiration.7003.desc
		triggered_desc = {
			trigger = { exists = scope:dedication_e }
			desc = fund_inspiration.7003.desc_e
		}
		triggered_desc = {
			trigger = { exists = scope:dedication_f }
			desc = fund_inspiration.7003.desc_f
		}
		desc = fund_inspiration.7003.desc_end
	}
	theme = realm

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	right_portrait = { 
		character = root
		animation = happiness
	}

	lower_left_portrait = scope:dedication_e
	lower_center_portrait = scope:dedication_f

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			NOR = { 
				has_variable = inspiration_dedication_var
				has_variable = inspiration_mod_choice_var
				has_inspiration_type = adventure_inspiration
				has_inspiration_type = alchemy_inspiration
				inspiration_owner = { has_variable = banner_commission }
			}
		}
		OR = {		
			any_relation = {
				type = potential_friend
			}
			any_relation = {
				type = potential_lover
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			any_relation = {
				type = potential_friend
			}
			any_relation = {
				type = potential_lover
			}
			add = 2
		}
	}

	immediate = {
		scope:inspiration = {
			set_variable = inspiration_dedication_var
		}
		if = {
			limit = {
				any_relation = {
					type = potential_friend
				}
			}
			random_relation = {
				type = potential_friend
				save_scope_as = dedication_e
			}
		}
		if = {
			limit = {
				any_relation = {
					type = potential_lover
					NAND = {
						exists = scope:dedication_e
						this = scope:dedication_e
					}
				}
			}
			random_relation = {
				type = potential_lover
				limit = {
					NAND = {
						exists = scope:dedication_e
						this = scope:dedication_e
					}
				}
				save_scope_as = dedication_f
			}
		}
	}

	#Option A: potential friend
	option = {
		name = fund_inspiration.7003.a
		trigger = {
			exists = scope:dedication_e
		}
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_dedication_e_var
				value = scope:dedication_e
			}
		}
		scope:dedication_e = {
			set_relation_friend = { reason = friend_dedicated_artifact target = root }
			add_opinion = {
				target = root
				modifier = impressed_opinion
				opinion = 20
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = gregarious
				add = 50
			}
		}
	}

	#Option B: potential lover
	option = {
		name = fund_inspiration.7003.b
		trigger = {
			exists = scope:dedication_f
		}
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_dedication_f_var
				value = scope:dedication_f
			}
		}
		scope:dedication_f = {
			set_relation_lover = { reason = lover_dedicated_artifact target = root involved_character = scope:inspiration_owner }
			add_opinion = {
				target = root
				modifier = impressed_opinion
				opinion = 20
			}
		}
		ai_chance = {
			base = 100
			modifier = {
				has_focus = intrigue_temptation_focus
				add = 50
			}
		}
	}

	#Option C: no
	option = {
		name = fund_inspiration.7003.c
		ai_chance = 80
	}
}

fund_inspiration.7004 = {
	type = character_event
	title = fund_inspiration.7004.t
	desc = fund_inspiration.7004.desc
	theme = realm

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	right_portrait = { 
		character = root
		animation = happiness
	}

	lower_left_portrait = scope:dedication_g1
	lower_center_portrait = scope:dedication_g2

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			NOR = { 
				has_variable = inspiration_dedication_var
				has_variable = inspiration_mod_choice_var
				has_inspiration_type = adventure_inspiration
				has_inspiration_type = alchemy_inspiration
				inspiration_owner = { has_variable = banner_commission }
			}
		}
		any_vassal = {
			count >= 2
			is_powerful_vassal = yes
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			any_vassal = {
				has_any_bad_relationship_with_root_trigger = yes
				is_powerful_vassal = yes
			}
			add = 1
		}
	}

	immediate = {
		scope:inspiration = {
			set_variable = inspiration_dedication_var
		}
		random_vassal = {
			limit = {
				is_powerful_vassal = yes
			}
			save_scope_as = dedication_g1
		}
		random_vassal = {
			limit = {
				is_powerful_vassal = yes
				NOT = { this = scope:dedication_g1 }
			}
			save_scope_as = dedication_g2
		}
	}

	#Option A: vassals
	option = {
		name = fund_inspiration.7004.a
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_dedication_g1_var
				value = scope:dedication_g1
			}
			set_variable = {
				name = artifact_dedication_g2_var
				value = scope:dedication_g2
			}
		}
		reverse_add_opinion = {
			target = scope:dedication_g1
			modifier = grateful_opinion
			opinion = 50
		}
		reverse_add_opinion = {
			target = scope:dedication_g2
			modifier = grateful_opinion
			opinion = 50
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = humble
				add = 50
			}
			modifier = {
				has_trait = arrogant
				add = -50
			}
		}
	}

	#Option B: just me
	option = {
		name = fund_inspiration.7004.b
		add_prestige = medium_prestige_gain
		scope:inspiration_owner = {
			set_variable = {
				name = artifact_dedication_h_var
				value = flag:dedication_h
			}
		}
		stress_impact = {
			humble = major_stress_impact_gain
		}
		ai_chance = {
			base = 100
			modifier = {
				has_trait = humble
				add = -50
			}
			modifier = {
				has_trait = arrogant
				add = 50
			}
		}
	}

	#Option C: no one
	option = {
		name = fund_inspiration.7004.c
		add_piety = medium_piety_gain
		ai_chance = {
			base = 80
		}
	}
}

# Add your family motto
fund_inspiration.7010 = {
	type = character_event
	title = fund_inspiration.7010.t
	desc = fund_inspiration.7010.desc
	theme = realm

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	right_portrait = { 
		character = root
		animation = happiness
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			NOR = { 
				has_variable = inspiration_dedication_var
				has_variable = inspiration_mod_choice_var
				has_inspiration_type = adventure_inspiration
				has_inspiration_type = alchemy_inspiration
				inspiration_owner = { has_variable = banner_commission }
			}
		}
	}

	immediate = {
		scope:inspiration = {
			set_variable = inspiration_dedication_var
		}
	}

	#Option A: family motto
	option = {
		name = fund_inspiration.7010.a
		scope:inspiration_owner = {
			set_variable = artifact_inscribe_motto_var
		}
		dynasty = { add_dynasty_prestige = minor_dynasty_prestige_gain }
		ai_chance = {
			base = 100
			modifier = {
				has_trait = family_first
				add = 100
			}
			modifier = {
				has_focus = diplomacy_majesty_focus
				add = 50
			}
		}
	}

	#Option B: no need
	option = {
		name = fund_inspiration.7010.b
		add_piety = medium_piety_gain
		ai_chance = {
			base = 80
			modifier = {
				has_trait = humble
				add = 50
			}
		}
	}
}

# Choose a theme for modifiers - weapons and armor
fund_inspiration.7100 = {
	type = character_event
	title = fund_inspiration.7100.t
	desc = fund_inspiration.7100.desc
	theme = realm

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	right_portrait = { 
		character = root
		animation = happiness
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			NOR = { 
				has_variable = inspiration_dedication_var
				has_variable = inspiration_mod_choice_var
			}
			OR = {
				has_inspiration_type = weapon_inspiration
				has_inspiration_type = armor_inspiration
			}
		}
		trigger_if = {
			limit = {
				scope:inspiration_owner = { has_variable = artifact_weapon_type }
			}
			NOT = { scope:inspiration_owner.var:artifact_weapon_type = flag:artifact_weapon_type_dagger }
		}
	}

	immediate = {
		scope:inspiration = {
			set_variable = inspiration_mod_choice_var
		}
	}

	#Option A: 
	option = {
		name = fund_inspiration.7100.a
		scope:inspiration_owner = { set_variable = chosen_casualties_mod }
		custom_tooltip = fund_inspiration.7100.a.tt
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_zeal = 1
			}
		}	
	}

	#Option B: raid
	option = {
		name = fund_inspiration.7100.b
		trigger = {
			can_raid_trigger = yes
		}
		scope:inspiration_owner = { set_variable = chosen_raid_mod }
		custom_tooltip = fund_inspiration.7100.b.tt
		ai_chance = {
			base = 150
		}
	}

	#Option C: knights
	option = {
		name = fund_inspiration.7100.c
		scope:inspiration_owner = { set_variable = chosen_knights_mod }
		custom_tooltip = fund_inspiration.7100.c.tt
		ai_chance = {
			base = 100
			modifier = {
				has_trait = brave
				add = 50
			}
			modifier = {
				has_focus = martial_chivalry_focus
				add = 50
			}
		}
	}

	#Option D: terrain advantage
	option = {
		name = fund_inspiration.7100.d
		trigger = {
			scope:inspiration = { has_inspiration_type = weapon_inspiration }
		}
		scope:inspiration_owner = { set_variable = chosen_terrain_mod }
		custom_tooltip = fund_inspiration.7100.d.tt
		ai_chance = {
			base = 100		
		}
	}

	#Option E: whatever
	option = {
		name = fund_inspiration.7100.e
		custom_tooltip = fund_inspiration.7100.e.tt
		ai_chance = {
			base = 80
		}
	}
}

# Choose a theme for modifiers - regalia/crowns
fund_inspiration.7110 = {
	type = character_event
	title = fund_inspiration.7100.t
	desc = fund_inspiration.7100.desc
	theme = realm

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	right_portrait = { 
		character = root
		animation = happiness
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			NOR = { 
				has_variable = inspiration_dedication_var
				has_variable = inspiration_mod_choice_var
			}
			has_inspiration_type = smith_inspiration
		}
		trigger_if = {
			limit = {
				scope:inspiration_owner = { has_variable = artifact_smith_type }
			}
			NOR = {
				scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_brooch
				scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_goblet
			}
		}
	}

	immediate = {
		scope:inspiration = {
			set_variable = inspiration_mod_choice_var
		}
	}

	#Option A: independent ruler opinion
	option = {
		name = fund_inspiration.7110.a
		trigger = {
			scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_crown
		}
		scope:inspiration_owner = { set_variable = chosen_ind_ruler_mod }
		custom_tooltip = fund_inspiration.7110.a.tt
		ai_chance = {
			base = 100
			modifier = {
				has_trait = arrogant
				add = 50
			}
			modifier = {
				has_trait = august
				add = 50
			}
			modifier = {
				has_focus = diplomacy_majesty_focus
				add = 50
			}
		}
	}

	#Option B: dynasty
	option = {
		name = fund_inspiration.7110.b
		trigger = {
			scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_regalia
		}
		scope:inspiration_owner = { set_variable = chosen_dynasty_mod }
		custom_tooltip = fund_inspiration.7110.b.tt
		ai_chance = {
			base = 100
			modifier = {
				has_trait = family_first
				add = 50
			}
			modifier = {
				has_focus = diplomacy_family_focus
				add = 50
			}
		}
	}

	#Option C: dread/tyranny
	option = {
		name = fund_inspiration.7110.c
		trigger = {
			scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_regalia
		}
		scope:inspiration_owner = { set_variable = chosen_dread_mod }
		custom_tooltip = fund_inspiration.7110.c.tt
		ai_chance = {
			base = 100
			modifier = {
				has_trait = callous
				add = 50
			}
			modifier = {
				has_trait = sadistic
				add = 50
			}
			modifier = {
				has_trait = compassionate
				add = -100
			}
			modifier = {
				has_focus = intrigue_intimidation_focus
				add = 50
			}
		}
	}

	#Option D: attraction
	option = {
		name = fund_inspiration.7110.d
		trigger = {
			scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_regalia
		}
		scope:inspiration_owner = { set_variable = chosen_attraction_mod }
		custom_tooltip = fund_inspiration.7110.d.tt
		ai_chance = {
			base = 100
			modifier = {
				has_trait = seducer
				add = 50
			}
			modifier = {
				has_trait = lustful
				add = 50
			}
			modifier = {
				has_trait = chaste
				add = -100
			}
			modifier = {
				has_focus = intrigue_temptation_focus
				add = 50
			}
		}
	}

	#Option E: vassals
	option = {
		name = fund_inspiration.7110.e
		trigger = {
			scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_crown
		}
		scope:inspiration_owner = { set_variable = chosen_vassals_mod }
		custom_tooltip = fund_inspiration.7110.e.tt
		ai_chance = {
			base = 100
			modifier = {
				has_trait = gregarious
				add = 50
			}
			modifier = {
				has_focus = stewardship_domain_focus
				add = 50
			}
		}
	}

	#Option G: courtier and guest opinion
	option = {
		name = fund_inspiration.7110.g
		trigger = {
			scope:inspiration_owner.var:artifact_smith_type = flag:smith_type_crown
		}
		scope:inspiration_owner = { set_variable = chosen_court_op_mod }
		custom_tooltip = fund_inspiration.7110.g.tt
		ai_chance = {
			base = 100
		}
	}

	#Option F: whatever
	option = {
		name = fund_inspiration.7100.e
		custom_tooltip = fund_inspiration.7100.e.tt
		ai_chance = {
			base = 80
		}
	}
}

# Choose a theme for modifiers - sculpture/throne
fund_inspiration.7120 = {
	type = character_event
	title = fund_inspiration.7100.t
	desc = fund_inspiration.7100.desc
	theme = realm

	left_portrait = { 
		character = scope:inspiration_owner
		animation = personality_bold
	}

	right_portrait = { 
		character = root
		animation = happiness
	}

	trigger = {
		exists = scope:inspiration
		scope:inspiration = {
			NOR = { 
				has_variable = inspiration_dedication_var
				has_variable = inspiration_mod_choice_var
			}
			has_inspiration_type = artisan_inspiration
		}
		trigger_if = {
			limit = {
				scope:inspiration_owner = { has_variable = artifact_artisan_type }
			}
			scope:inspiration_owner.var:artifact_artisan_type = flag:artisan_type_sculpture
			scope:inspiration_owner.var:artifact_artisan_type = flag:artisan_type_throne
		}
	}

	immediate = {
		scope:inspiration = {
			set_variable = inspiration_mod_choice_var
		}
	}

	#Option A: short reign
	option = {
		name = fund_inspiration.7120.a
		trigger = { has_royal_court = yes }
		scope:inspiration_owner = { set_variable = chosen_reign_mod }
		custom_tooltip = fund_inspiration.7120.a.tt
		ai_chance = {
			base = 100
			modifier = {
				has_trait = shy
				add = 100
			}
			modifier = {
				has_trait = craven
				add = 100
			}
			modifier = {
				has_trait = paranoid
				add = 100
			}
		}
	}

	#Option B: dynasty
	option = {
		name = fund_inspiration.7110.b
		scope:inspiration_owner = { set_variable = chosen_dynasty_mod }
		custom_tooltip = fund_inspiration.7110.b.tt
		ai_chance = {
			base = 100
			modifier = {
				has_trait = family_first
				add = 50
			}
			modifier = {
				has_focus = diplomacy_family_focus
				add = 50
			}
		}
	}

	#Option C: dread/tyranny
	option = {
		name = fund_inspiration.7110.c
		scope:inspiration_owner = { set_variable = chosen_dread_mod }
		custom_tooltip = fund_inspiration.7110.c.tt
		ai_chance = {
			base = 100
			modifier = {
				has_trait = callous
				add = 50
			}
			modifier = {
				has_trait = sadistic
				add = 50
			}
			modifier = {
				has_trait = compassionate
				add = -100
			}
			modifier = {
				has_focus = intrigue_intimidation_focus
				add = 50
			}
		}
	}

	#Option E: whatever
	option = {
		name = fund_inspiration.7100.e
		custom_tooltip = fund_inspiration.7100.e.tt
		ai_chance = {
			base = 100
		}
	}
}
